Skip to content

Commit 63beec4

Browse files
committed
Minor improvements and code style checks
1 parent 00cff5f commit 63beec4

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/main/java/io/api/etherscan/core/impl/EtherScanApi.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public EtherScanApi(final String apiKey,
6565
throw new ApiException("Ethereum Network is set to NULL value");
6666

6767
// EtherScan 5request\sec limit support by queue manager
68-
final IQueueManager masterQueue = (apiKey.equals("YourApiKeyToken"))
68+
final IQueueManager masterQueue = "YourApiKeyToken".equals(apiKey)
6969
? new FakeQueueManager()
7070
: new QueueManager(5, 1);
7171

src/main/java/io/api/etherscan/error/ConnectionException.java

-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package io.api.etherscan.error;
22

33
/**
4-
* ! NO DESCRIPTION !
5-
*
64
* @author GoodforGod
75
* @since 29.10.2018
86
*/

src/main/java/io/api/etherscan/executor/impl/HttpExecutor.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public String get(final String urlAsString) {
9696
} catch (SocketTimeoutException e) {
9797
throw new ApiTimeoutException("Timeout: Could not establish connection for " + connectTimeout + " millis", e);
9898
} catch (Exception e) {
99-
throw new ConnectionException(e.getLocalizedMessage(), e);
99+
throw new ConnectionException(e.getMessage(), e);
100100
}
101101
}
102102

@@ -126,7 +126,7 @@ public String post(final String urlAsString, final String dataToPost) {
126126
} catch (SocketTimeoutException e) {
127127
throw new ApiTimeoutException("Timeout: Could not establish connection for " + connectTimeout + " millis", e);
128128
} catch (Exception e) {
129-
throw new ConnectionException(e.getLocalizedMessage(), e);
129+
throw new ConnectionException(e.getMessage(), e);
130130
}
131131
}
132132

@@ -136,8 +136,6 @@ private String readData(final HttpURLConnection connection) throws IOException {
136136
String inputLine;
137137
while ((inputLine = in.readLine()) != null)
138138
content.append(inputLine);
139-
140-
in.close();
141139
}
142140

143141
return content.toString();
@@ -146,11 +144,11 @@ private String readData(final HttpURLConnection connection) throws IOException {
146144
private InputStreamReader getStreamReader(final HttpURLConnection connection) throws IOException {
147145
switch (String.valueOf(connection.getContentEncoding())) {
148146
case "gzip":
149-
return new InputStreamReader(new GZIPInputStream(connection.getInputStream()), "utf-8");
147+
return new InputStreamReader(new GZIPInputStream(connection.getInputStream()), StandardCharsets.UTF_8);
150148
case "deflate":
151-
return new InputStreamReader(new InflaterInputStream(connection.getInputStream()), "utf-8");
149+
return new InputStreamReader(new InflaterInputStream(connection.getInputStream()), StandardCharsets.UTF_8);
152150
default:
153-
return new InputStreamReader(connection.getInputStream(), "utf-8");
151+
return new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8);
154152
}
155153
}
156154
}

src/test/java/io/api/etherscan/account/AccountBalanceListTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.junit.Assert;
88
import org.junit.Test;
99

10+
import java.math.BigInteger;
1011
import java.util.ArrayList;
1112
import java.util.List;
1213

@@ -18,7 +19,7 @@
1819
*/
1920
public class AccountBalanceListTest extends Assert {
2021

21-
private EtherScanApi api = new EtherScanApi();
22+
private final EtherScanApi api = new EtherScanApi();
2223

2324
@Test
2425
public void correct() {
@@ -40,7 +41,7 @@ public void correct() {
4041
assertNotNull(balance.getEther());
4142
assertNotNull(balance.getGwei());
4243
assertNotNull(balance.getAddress());
43-
assertNotEquals(0, balance.getWei());
44+
assertNotEquals(BigInteger.ZERO, balance.getWei());
4445
assertNotNull(balance.toString());
4546
}
4647
}

src/test/java/io/api/etherscan/account/AccountBalanceTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.junit.runners.Parameterized;
1111
import org.junit.runners.Parameterized.Parameters;
1212

13+
import java.math.BigInteger;
1314
import java.util.Arrays;
1415
import java.util.Collection;
1516

@@ -74,7 +75,7 @@ public void correct() {
7475
assertNotNull(balance.getGwei());
7576
assertNotNull(balance.getEther());
7677
assertNotNull(balance.getAddress());
77-
assertNotEquals(0, balance.getWei());
78+
assertNotEquals(BigInteger.ZERO, balance.getWei());
7879
assertNotNull(balance.toString());
7980
}
8081

0 commit comments

Comments
 (0)