Skip to content

Commit 25751ab

Browse files
committed
[2.0.0-SNAPSHOT]
Default converter parsing optimized
1 parent f5b2edb commit 25751ab

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/io/goodforgod/api/etherscan/EthScanAPIBuilder.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
import com.google.gson.Gson;
44
import io.goodforgod.api.etherscan.error.EtherScanKeyException;
5+
import io.goodforgod.api.etherscan.error.EtherScanParseException;
56
import io.goodforgod.api.etherscan.http.EthHttpClient;
67
import io.goodforgod.api.etherscan.http.impl.UrlEthHttpClient;
78
import io.goodforgod.api.etherscan.manager.RequestQueueManager;
89
import io.goodforgod.api.etherscan.util.BasicUtils;
910
import io.goodforgod.gson.configuration.GsonConfiguration;
11+
import java.io.ByteArrayInputStream;
12+
import java.io.IOException;
13+
import java.io.InputStreamReader;
1014
import java.nio.charset.StandardCharsets;
1115
import java.util.function.Supplier;
1216
import org.jetbrains.annotations.NotNull;
@@ -30,8 +34,11 @@ final class EthScanAPIBuilder implements EtherScanAPI.Builder {
3034

3135
@Override
3236
public <T> @NotNull T fromJson(byte[] jsonAsByteArray, @NotNull Class<T> type) {
33-
final String jsonAsString = new String(jsonAsByteArray, StandardCharsets.UTF_8);
34-
return gson.fromJson(jsonAsString, type);
37+
try (InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(jsonAsByteArray))) {
38+
return gson.fromJson(isr, type);
39+
} catch (IOException e) {
40+
throw new EtherScanParseException(e.getMessage(), e, new String(jsonAsByteArray, StandardCharsets.UTF_8));
41+
}
3542
}
3643
};
3744

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy