diff --git a/src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java b/src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java index f4f2b6496..54062afae 100644 --- a/src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java +++ b/src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java @@ -53,7 +53,7 @@ public void testContractCreation() throws Exception { List uint = FunctionReturnDecoder.decode( responseValue, function.getOutputParameters()); assertThat(uint.size(), is(1)); - assertThat(uint.get(0).getValue(), equalTo(BigInteger.valueOf(13))); + assertThat((BigInteger) uint.get(0).getValue(), equalTo(BigInteger.valueOf(13))); } private String sendTransaction() throws Exception { diff --git a/src/integration-test/java/org/web3j/protocol/scenarios/GreeterContractIT.java b/src/integration-test/java/org/web3j/protocol/scenarios/GreeterContractIT.java index 4df64d3e4..f34e33cc0 100644 --- a/src/integration-test/java/org/web3j/protocol/scenarios/GreeterContractIT.java +++ b/src/integration-test/java/org/web3j/protocol/scenarios/GreeterContractIT.java @@ -60,7 +60,7 @@ public void testGreeterContract() throws Exception { List response = FunctionReturnDecoder.decode( responseValue, getFunction.getOutputParameters()); assertThat(response.size(), is(1)); - assertThat(response.get(0).getValue(), is(VALUE)); + assertThat((String) response.get(0).getValue(), is(VALUE)); } private String sendCreateContractTransaction() throws Exception { @@ -104,7 +104,7 @@ private static String getGreeterSolidityBinary() throws Exception { Function createGreetFunction() { return new Function( "greet", - Collections.emptyList(), - Collections.singletonList(new TypeReference() {})); + Collections.emptyList(), + Collections.>singletonList(new TypeReference() {})); } } diff --git a/src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java b/src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java index a1b4f6644..7a435e2e1 100644 --- a/src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java +++ b/src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java @@ -105,7 +105,7 @@ private void confirmBalance( List response = FunctionReturnDecoder.decode( responseValue, function.getOutputParameters()); assertThat(response.size(), is(1)); - assertThat(response.get(0), equalTo(new Uint256(expected))); + assertThat((Uint256) response.get(0), equalTo(new Uint256(expected))); } private void confirmAllowance(String owner, String spender, String contractAddress, @@ -117,7 +117,7 @@ private void confirmAllowance(String owner, String spender, String contractAddre responseValue, function.getOutputParameters()); assertThat(response.size(), is(function.getOutputParameters().size())); - assertThat(response.get(0), equalTo(new Uint256(expected))); + assertThat((Uint256) response.get(0), equalTo(new Uint256(expected))); } private String createContract( @@ -301,43 +301,43 @@ private String callSmartContractFunction( private Function totalSupply() { return new Function( "totalSupply", - Collections.emptyList(), - Collections.singletonList(new TypeReference() {})); + Collections.emptyList(), + Collections.>singletonList(new TypeReference() {})); } private Function balanceOf(String owner) { return new Function( "balanceOf", - Collections.singletonList(new Address(owner)), - Collections.singletonList(new TypeReference() {})); + Collections.singletonList(new Address(owner)), + Collections.>singletonList(new TypeReference() {})); } private Function transfer(String to, BigInteger value) { return new Function( "transfer", - Arrays.asList(new Address(to), new Uint256(value)), - Collections.singletonList(new TypeReference() {})); + Arrays.asList(new Address(to), new Uint256(value)), + Collections.>singletonList(new TypeReference() {})); } private Function allowance(String owner, String spender) { return new Function( "allowance", - Arrays.asList(new Address(owner), new Address(spender)), - Collections.singletonList(new TypeReference() {})); + Arrays.asList(new Address(owner), new Address(spender)), + Collections.>singletonList(new TypeReference() {})); } private Function approve(String spender, BigInteger value) { return new Function( "approve", - Arrays.asList(new Address(spender), new Uint256(value)), - Collections.singletonList(new TypeReference() {})); + Arrays.asList(new Address(spender), new Uint256(value)), + Collections.>singletonList(new TypeReference() {})); } private Function transferFrom(String from, String to, BigInteger value) { return new Function( "transferFrom", - Arrays.asList(new Address(from), new Address(to), new Uint256(value)), - Collections.singletonList(new TypeReference() {})); + Arrays.asList(new Address(from), new Address(to), new Uint256(value)), + Collections.>singletonList(new TypeReference() {})); } private Event transferEvent() { diff --git a/src/main/java/org/web3j/abi/Contract.java b/src/main/java/org/web3j/abi/Contract.java index 621fab714..f9580f763 100644 --- a/src/main/java/org/web3j/abi/Contract.java +++ b/src/main/java/org/web3j/abi/Contract.java @@ -69,9 +69,9 @@ public T call() throws Exception { }); } - protected Future> executeCallMultipleValueReturnAsync( + protected Future> executeCallMultipleValueReturnAsync( final Function function) { - return Async.run(new Callable>() { + return Async.run(new Callable>() { @Override public List call() throws Exception { return executeCallMultipleValueReturn(function); diff --git a/src/main/java/org/web3j/abi/Utils.java b/src/main/java/org/web3j/abi/Utils.java index 96b3a0d41..be0d5696e 100644 --- a/src/main/java/org/web3j/abi/Utils.java +++ b/src/main/java/org/web3j/abi/Utils.java @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; @@ -83,10 +82,12 @@ static Class getParameterizedTypeFromArray( @SuppressWarnings("unchecked") public static List> convert(List> input) { - List> result = new ArrayList<>(input.size()); - result.addAll(input.stream() - .map(typeReference -> (TypeReference) typeReference) - .collect(Collectors.toList())); + List> result = new ArrayList>(input.size()); + + for (TypeReference typeReference:input) { + result.add((TypeReference) typeReference); + } + return result; } } diff --git a/src/main/java/org/web3j/protocol/infura/CertificateManager.java b/src/main/java/org/web3j/protocol/infura/CertificateManager.java index 02776ad7e..dea67ee93 100644 --- a/src/main/java/org/web3j/protocol/infura/CertificateManager.java +++ b/src/main/java/org/web3j/protocol/infura/CertificateManager.java @@ -100,7 +100,7 @@ private static boolean isTrustedEndPoint(SSLSocket socket) throws IOException { } } - private static void deleteFileOnShutdown(File file) { + private static void deleteFileOnShutdown(final File file) { Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { try { diff --git a/src/main/java/org/web3j/protocol/infura/InfuraHttpService.java b/src/main/java/org/web3j/protocol/infura/InfuraHttpService.java index 66c441de5..e4e3a7736 100644 --- a/src/main/java/org/web3j/protocol/infura/InfuraHttpService.java +++ b/src/main/java/org/web3j/protocol/infura/InfuraHttpService.java @@ -6,7 +6,6 @@ import java.security.*; import java.security.cert.CertificateException; import java.util.List; -import java.util.Optional; import org.apache.http.Header; import org.apache.http.impl.client.CloseableHttpClient; @@ -26,7 +25,7 @@ public class InfuraHttpService extends HttpService { private static final char[] TEMP_KEY_STORE_PASSWORD = "web3j runtime cert store".toCharArray(); - private final Optional
clientVersionHeader; + private final Header clientVersionHeader; public InfuraHttpService(String url, String clientVersion, boolean required) { super(url); @@ -44,21 +43,21 @@ public InfuraHttpService(String url) { @Override protected void addHeaders(List
headers) { - if (clientVersionHeader.isPresent()) { - headers.add(clientVersionHeader.get()); + if (clientVersionHeader != null) { + headers.add(clientVersionHeader); } } - static Optional
buildHeader(String clientVersion, boolean required) { + static Header buildHeader(String clientVersion, boolean required) { if (clientVersion == null || clientVersion.equals("")) { - return Optional.empty(); + return null; } if (required) { - return Optional.of(new BasicHeader(INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion)); + return new BasicHeader(INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion); } else { - return Optional.of(new BasicHeader( - INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion + "; required=false")); + return new BasicHeader( + INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion + "; required=false"); } } diff --git a/src/test/java/org/web3j/abi/FunctionReturnDecoderTest.java b/src/test/java/org/web3j/abi/FunctionReturnDecoderTest.java index d629da581..93d5f576c 100644 --- a/src/test/java/org/web3j/abi/FunctionReturnDecoderTest.java +++ b/src/test/java/org/web3j/abi/FunctionReturnDecoderTest.java @@ -49,7 +49,7 @@ public void testSimpleFunctionStringResultDecode() { "6f6e65206d6f72652074696d6500000000000000000000000000000000000000", function.getOutputParameters()); - assertThat(utf8Strings.get(0).getValue(), is("one more time")); + assertThat((String) utf8Strings.get(0).getValue(), is("one more time")); } @Test @@ -64,7 +64,7 @@ public void testFunctionEmptyStringResultDecode() { "0000000000000000000000000000000000000000000000000000000000000000", function.getOutputParameters()); - assertThat(utf8Strings.get(0).getValue(), is("")); + assertThat((String) utf8Strings.get(0).getValue(), is("")); } @Test @@ -72,7 +72,8 @@ public void testMultipleResultFunctionDecode() { Function function = new Function( "test", Collections.emptyList(), - Arrays.asList(new TypeReference() { }, new TypeReference() { }) + Arrays.>asList( + new TypeReference() { }, new TypeReference() { }) ); assertThat(FunctionReturnDecoder.decode( diff --git a/src/test/java/org/web3j/protocol/infura/InfuraHttpServiceTest.java b/src/test/java/org/web3j/protocol/infura/InfuraHttpServiceTest.java index a75c8b13e..7680076f7 100644 --- a/src/test/java/org/web3j/protocol/infura/InfuraHttpServiceTest.java +++ b/src/test/java/org/web3j/protocol/infura/InfuraHttpServiceTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.web3j.protocol.infura.InfuraHttpService.buildHeader; @@ -13,15 +13,15 @@ public class InfuraHttpServiceTest { @Test public void testBuildHeader() { - assertFalse(buildHeader("", false).isPresent()); - assertFalse(buildHeader(null, false).isPresent()); + assertNull(buildHeader("", false)); + assertNull(buildHeader(null, false)); - assertThat(buildHeader("geth 1.4.19", true).get().toString(), + assertThat(buildHeader("geth 1.4.19", true).toString(), is(new BasicHeader( "Infura-Ethereum-Preferred-Client", "geth 1.4.19").toString())); - assertThat(buildHeader("geth 1.4.19", false).get().toString(), + assertThat(buildHeader("geth 1.4.19", false).toString(), is(new BasicHeader( "Infura-Ethereum-Preferred-Client", "geth 1.4.19; required=false").toString()));