Skip to content

Commit 0de4455

Browse files
committed
Additional modifications that weren't included in the merge.
1 parent 4542253 commit 0de4455

File tree

9 files changed

+44
-43
lines changed

9 files changed

+44
-43
lines changed

src/integration-test/java/org/web3j/protocol/scenarios/DeployContractIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testContractCreation() throws Exception {
5353
List<Type> uint = FunctionReturnDecoder.decode(
5454
responseValue, function.getOutputParameters());
5555
assertThat(uint.size(), is(1));
56-
assertThat(uint.get(0).getValue(), equalTo(BigInteger.valueOf(13)));
56+
assertThat((BigInteger) uint.get(0).getValue(), equalTo(BigInteger.valueOf(13)));
5757
}
5858

5959
private String sendTransaction() throws Exception {

src/integration-test/java/org/web3j/protocol/scenarios/GreeterContractIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void testGreeterContract() throws Exception {
6060
List<Type> response = FunctionReturnDecoder.decode(
6161
responseValue, getFunction.getOutputParameters());
6262
assertThat(response.size(), is(1));
63-
assertThat(response.get(0).getValue(), is(VALUE));
63+
assertThat((String) response.get(0).getValue(), is(VALUE));
6464
}
6565

6666
private String sendCreateContractTransaction() throws Exception {
@@ -104,7 +104,7 @@ private static String getGreeterSolidityBinary() throws Exception {
104104
Function createGreetFunction() {
105105
return new Function(
106106
"greet",
107-
Collections.emptyList(),
108-
Collections.singletonList(new TypeReference<Utf8String>() {}));
107+
Collections.<Type>emptyList(),
108+
Collections.<TypeReference<?>>singletonList(new TypeReference<Utf8String>() {}));
109109
}
110110
}

src/integration-test/java/org/web3j/protocol/scenarios/HumanStandardTokenIT.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private void confirmBalance(
105105
List<Type> response = FunctionReturnDecoder.decode(
106106
responseValue, function.getOutputParameters());
107107
assertThat(response.size(), is(1));
108-
assertThat(response.get(0), equalTo(new Uint256(expected)));
108+
assertThat((Uint256) response.get(0), equalTo(new Uint256(expected)));
109109
}
110110

111111
private void confirmAllowance(String owner, String spender, String contractAddress,
@@ -117,7 +117,7 @@ private void confirmAllowance(String owner, String spender, String contractAddre
117117
responseValue, function.getOutputParameters());
118118

119119
assertThat(response.size(), is(function.getOutputParameters().size()));
120-
assertThat(response.get(0), equalTo(new Uint256(expected)));
120+
assertThat((Uint256) response.get(0), equalTo(new Uint256(expected)));
121121
}
122122

123123
private String createContract(
@@ -301,43 +301,43 @@ private String callSmartContractFunction(
301301
private Function totalSupply() {
302302
return new Function(
303303
"totalSupply",
304-
Collections.emptyList(),
305-
Collections.singletonList(new TypeReference<Uint256>() {}));
304+
Collections.<Type>emptyList(),
305+
Collections.<TypeReference<?>>singletonList(new TypeReference<Uint256>() {}));
306306
}
307307

308308
private Function balanceOf(String owner) {
309309
return new Function(
310310
"balanceOf",
311-
Collections.singletonList(new Address(owner)),
312-
Collections.singletonList(new TypeReference<Uint256>() {}));
311+
Collections.<Type>singletonList(new Address(owner)),
312+
Collections.<TypeReference<?>>singletonList(new TypeReference<Uint256>() {}));
313313
}
314314

315315
private Function transfer(String to, BigInteger value) {
316316
return new Function(
317317
"transfer",
318-
Arrays.asList(new Address(to), new Uint256(value)),
319-
Collections.singletonList(new TypeReference<Bool>() {}));
318+
Arrays.<Type>asList(new Address(to), new Uint256(value)),
319+
Collections.<TypeReference<?>>singletonList(new TypeReference<Bool>() {}));
320320
}
321321

322322
private Function allowance(String owner, String spender) {
323323
return new Function(
324324
"allowance",
325-
Arrays.asList(new Address(owner), new Address(spender)),
326-
Collections.singletonList(new TypeReference<Uint256>() {}));
325+
Arrays.<Type>asList(new Address(owner), new Address(spender)),
326+
Collections.<TypeReference<?>>singletonList(new TypeReference<Uint256>() {}));
327327
}
328328

329329
private Function approve(String spender, BigInteger value) {
330330
return new Function(
331331
"approve",
332-
Arrays.asList(new Address(spender), new Uint256(value)),
333-
Collections.singletonList(new TypeReference<Bool>() {}));
332+
Arrays.<Type>asList(new Address(spender), new Uint256(value)),
333+
Collections.<TypeReference<?>>singletonList(new TypeReference<Bool>() {}));
334334
}
335335

336336
private Function transferFrom(String from, String to, BigInteger value) {
337337
return new Function(
338338
"transferFrom",
339-
Arrays.asList(new Address(from), new Address(to), new Uint256(value)),
340-
Collections.singletonList(new TypeReference<Bool>() {}));
339+
Arrays.<Type>asList(new Address(from), new Address(to), new Uint256(value)),
340+
Collections.<TypeReference<?>>singletonList(new TypeReference<Bool>() {}));
341341
}
342342

343343
private Event transferEvent() {

src/main/java/org/web3j/abi/Contract.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public T call() throws Exception {
6969
});
7070
}
7171

72-
protected <Type> Future<List<T>> executeCallMultipleValueReturnAsync(
72+
protected Future<List<Type>> executeCallMultipleValueReturnAsync(
7373
final Function function) {
74-
return Async.run(new Callable<List<T>>() {
74+
return Async.run(new Callable<List<Type>>() {
7575
@Override
7676
public List<Type> call() throws Exception {
7777
return executeCallMultipleValueReturn(function);

src/main/java/org/web3j/abi/Utils.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5-
import java.util.stream.Collectors;
65

76
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
87

@@ -83,10 +82,12 @@ static <T extends Type> Class<T> getParameterizedTypeFromArray(
8382

8483
@SuppressWarnings("unchecked")
8584
public static List<TypeReference<Type>> convert(List<TypeReference<?>> input) {
86-
List<TypeReference<Type>> result = new ArrayList<>(input.size());
87-
result.addAll(input.stream()
88-
.map(typeReference -> (TypeReference<Type>) typeReference)
89-
.collect(Collectors.toList()));
85+
List<TypeReference<Type>> result = new ArrayList<TypeReference<Type>>(input.size());
86+
87+
for (TypeReference<?> typeReference:input) {
88+
result.add((TypeReference<Type>) typeReference);
89+
}
90+
9091
return result;
9192
}
9293
}

src/main/java/org/web3j/protocol/infura/CertificateManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private static boolean isTrustedEndPoint(SSLSocket socket) throws IOException {
100100
}
101101
}
102102

103-
private static void deleteFileOnShutdown(File file) {
103+
private static void deleteFileOnShutdown(final File file) {
104104
Runtime.getRuntime().addShutdownHook(new Thread() {
105105
public void run() {
106106
try {

src/main/java/org/web3j/protocol/infura/InfuraHttpService.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.security.*;
77
import java.security.cert.CertificateException;
88
import java.util.List;
9-
import java.util.Optional;
109

1110
import org.apache.http.Header;
1211
import org.apache.http.impl.client.CloseableHttpClient;
@@ -26,7 +25,7 @@ public class InfuraHttpService extends HttpService {
2625

2726
private static final char[] TEMP_KEY_STORE_PASSWORD = "web3j runtime cert store".toCharArray();
2827

29-
private final Optional<Header> clientVersionHeader;
28+
private final Header clientVersionHeader;
3029

3130
public InfuraHttpService(String url, String clientVersion, boolean required) {
3231
super(url);
@@ -44,21 +43,21 @@ public InfuraHttpService(String url) {
4443

4544
@Override
4645
protected void addHeaders(List<Header> headers) {
47-
if (clientVersionHeader.isPresent()) {
48-
headers.add(clientVersionHeader.get());
46+
if (clientVersionHeader != null) {
47+
headers.add(clientVersionHeader);
4948
}
5049
}
5150

52-
static Optional<Header> buildHeader(String clientVersion, boolean required) {
51+
static Header buildHeader(String clientVersion, boolean required) {
5352
if (clientVersion == null || clientVersion.equals("")) {
54-
return Optional.empty();
53+
return null;
5554
}
5655

5756
if (required) {
58-
return Optional.of(new BasicHeader(INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion));
57+
return new BasicHeader(INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion);
5958
} else {
60-
return Optional.of(new BasicHeader(
61-
INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion + "; required=false"));
59+
return new BasicHeader(
60+
INFURA_ETHEREUM_PREFERRED_CLIENT, clientVersion + "; required=false");
6261
}
6362
}
6463

src/test/java/org/web3j/abi/FunctionReturnDecoderTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void testSimpleFunctionStringResultDecode() {
4949
"6f6e65206d6f72652074696d6500000000000000000000000000000000000000",
5050
function.getOutputParameters());
5151

52-
assertThat(utf8Strings.get(0).getValue(), is("one more time"));
52+
assertThat((String) utf8Strings.get(0).getValue(), is("one more time"));
5353
}
5454

5555
@Test
@@ -64,15 +64,16 @@ public void testFunctionEmptyStringResultDecode() {
6464
"0000000000000000000000000000000000000000000000000000000000000000",
6565
function.getOutputParameters());
6666

67-
assertThat(utf8Strings.get(0).getValue(), is(""));
67+
assertThat((String) utf8Strings.get(0).getValue(), is(""));
6868
}
6969

7070
@Test
7171
public void testMultipleResultFunctionDecode() {
7272
Function function = new Function(
7373
"test",
7474
Collections.<Type>emptyList(),
75-
Arrays.asList(new TypeReference<Uint>() { }, new TypeReference<Uint>() { })
75+
Arrays.<TypeReference<?>>asList(
76+
new TypeReference<Uint>() { }, new TypeReference<Uint>() { })
7677
);
7778

7879
assertThat(FunctionReturnDecoder.decode(

src/test/java/org/web3j/protocol/infura/InfuraHttpServiceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
import org.junit.Test;
66

77
import static org.hamcrest.core.Is.is;
8-
import static org.junit.Assert.assertFalse;
8+
import static org.junit.Assert.assertNull;
99
import static org.junit.Assert.assertThat;
1010
import static org.web3j.protocol.infura.InfuraHttpService.buildHeader;
1111

1212
public class InfuraHttpServiceTest {
1313

1414
@Test
1515
public void testBuildHeader() {
16-
assertFalse(buildHeader("", false).isPresent());
17-
assertFalse(buildHeader(null, false).isPresent());
16+
assertNull(buildHeader("", false));
17+
assertNull(buildHeader(null, false));
1818

19-
assertThat(buildHeader("geth 1.4.19", true).get().toString(),
19+
assertThat(buildHeader("geth 1.4.19", true).toString(),
2020
is(new BasicHeader(
2121
"Infura-Ethereum-Preferred-Client",
2222
"geth 1.4.19").toString()));
2323

24-
assertThat(buildHeader("geth 1.4.19", false).get().toString(),
24+
assertThat(buildHeader("geth 1.4.19", false).toString(),
2525
is(new BasicHeader(
2626
"Infura-Ethereum-Preferred-Client",
2727
"geth 1.4.19; required=false").toString()));

0 commit comments

Comments
 (0)