web3j icon indicating copy to clipboard operation
web3j copied to clipboard

java.io.IOException: closed

Open qiujun8023 opened this issue 3 years ago • 0 comments

java.io.IOException: closed

For versions above 4.8.2, if includeRawResponse = true is set, the request will be Closed.

Steps To Reproduce

public class OPChainTest {
    private final static Web3j web3j = Web3j.build(new HttpService("https://kovan.optimism.io", true));

    public static void main(String[] args) throws Exception {
        String transactionHash = "0x81fa293787813e29adae234bd4364e6f87c0567e4c7bbac6e5c6e2c88ca144ef";

        EthGetTransactionReceipt transactionReceiptGet = web3j.ethGetTransactionReceipt(transactionHash).send();
        String rawResponse = transactionReceiptGet.getRawResponse();
        System.out.println(rawResponse);
    }
}

Expected behavior

The request is successful and the rawResponse can be obtained

Actual behavior

Exception in thread "main" java.io.IOException: closed
	at okio.RealBufferedSource$inputStream$1.read(RealBufferedSource.kt:154)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
	at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.ensureLoaded(ByteSourceJsonBootstrapper.java:522)
	at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.detectEncoding(ByteSourceJsonBootstrapper.java:129)
	at com.fasterxml.jackson.core.json.ByteSourceJsonBootstrapper.constructParser(ByteSourceJsonBootstrapper.java:246)
	at com.fasterxml.jackson.core.JsonFactory._createParser(JsonFactory.java:1271)
	at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:810)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2924)
	at org.web3j.protocol.Service.send(Service.java:50)
	at org.web3j.protocol.core.Request.send(Request.java:87)
	at xxxxxx.OPChainTest.main(OPChainTest.java:20)

Environment

Describe the environment in which the issue occurs

  • Web3j version >4.8.2, eg 4.8.4
  • Java 8
  • Operating System MacOS 12.4

Additional context

link to #1342

qiujun8023 avatar Jun 22 '22 15:06 qiujun8023