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