address some sonar cloud bugs (#3592)

* address some sonar cloud bugs

Signed-off-by: Sally MacFarlane <sally.macfarlane@consensys.net>
pull/3602/head
Sally MacFarlane 3 years ago committed by GitHub
parent a72becd7c5
commit e7d0e9552c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      CHANGELOG.md
  2. 38
      acceptance-tests/dsl/src/main/java/org/hyperledger/besu/tests/acceptance/dsl/node/BesuNode.java

@ -37,7 +37,7 @@
- Backward sync [#3410](https://github.com/hyperledger/besu/pull/3410)
- Extend validateAndProcessBlock to return an error message in case of failure, so it can be returned to the caller of ExecutePayload API [#3411](https://github.com/hyperledger/besu/pull/3411)
- Persist latest finalized block [#2913](https://github.com/hyperledger/besu/issues/2913)
- Add PostMergeContext, and stop syncing after the swith to PoS [#3453](https://github.com/hyperledger/besu/pull/3453)
- Add PostMergeContext, and stop syncing after the switch to PoS [#3453](https://github.com/hyperledger/besu/pull/3453)
- Add header validation rules needed to validate The Merge blocks [#3454](https://github.com/hyperledger/besu/pull/3454)
- Add core components: controller builder, protocol scheduler, coordinator, block creator and processor. [#3461](https://github.com/hyperledger/besu/pull/3461)
- Execution specific RPC endpoint [#2914](https://github.com/hyperledger/besu/issues/2914), [#3350](https://github.com/hyperledger/besu/pull/3350)

@ -82,6 +82,9 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private static final String LOCALHOST = "127.0.0.1";
private static final Logger LOG = LoggerFactory.getLogger(BesuNode.class);
public static final String HTTP = "http://";
public static final String WS_RPC = "ws-rpc";
public static final String JSON_RPC = "json-rpc";
private final Path homeDirectory;
private KeyPair keyPair;
@ -165,7 +168,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
}
});
keyPair.ifPresentOrElse(
(existingKeyPair) -> {
existingKeyPair -> {
this.keyPair = existingKeyPair;
KeyPairUtil.storeKeyFile(existingKeyPair, homeDirectory);
},
@ -206,7 +209,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this.isDnsEnabled = isDnsEnabled;
privacyParameters.ifPresent(this::setPrivacyParameters);
this.pkiKeyStoreConfiguration = pkiKeyStoreConfiguration;
LOG.info("Created BesuNode {}", this.toString());
LOG.info("Created BesuNode {}", this);
}
private static Path createTmpDataDirectory() {
@ -281,19 +284,20 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private Optional<String> jsonRpcBaseUrl() {
if (isJsonRpcEnabled()) {
return Optional.of(
"http://"
+ jsonRpcConfiguration.getHost()
+ ":"
+ portsProperties.getProperty("json-rpc"));
HTTP + jsonRpcConfiguration.getHost() + ":" + portsProperties.getProperty(JSON_RPC));
} else {
return Optional.empty();
}
}
public Optional<String> engineHttpUrl() {
if (isJsonRpcEnabled()) {
if (isEngineRpcEnabled()) {
final Optional<Integer> maybeEngineRpcPort = getEngineJsonRpcPort();
if (maybeEngineRpcPort.isEmpty()) {
return Optional.empty();
}
return Optional.of(
"http://" + jsonRpcConfiguration.getHost() + ":" + getEngineJsonRpcPort().get());
HTTP + engineRpcConfiguration.get().getHost() + ":" + maybeEngineRpcPort.get());
} else {
return Optional.empty();
}
@ -302,7 +306,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private Optional<String> wsRpcBaseUrl() {
if (isWebSocketsRpcEnabled()) {
return Optional.of(
"ws://" + webSocketConfiguration.getHost() + ":" + portsProperties.getProperty("ws-rpc"));
"ws://" + webSocketConfiguration.getHost() + ":" + portsProperties.getProperty(WS_RPC));
} else {
return Optional.empty();
}
@ -311,10 +315,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private Optional<String> wsRpcBaseHttpUrl() {
if (isWebSocketsRpcEnabled()) {
return Optional.of(
"http://"
+ webSocketConfiguration.getHost()
+ ":"
+ portsProperties.getProperty("ws-rpc"));
HTTP + webSocketConfiguration.getHost() + ":" + portsProperties.getProperty(WS_RPC));
} else {
return Optional.empty();
}
@ -323,7 +324,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public Optional<String> metricsHttpUrl() {
if (isMetricsEnabled()) {
return Optional.of(
"http://"
HTTP
+ metricsConfiguration.getHost()
+ ":"
+ portsProperties.getProperty("metrics")
@ -336,7 +337,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
@Override
public Optional<Integer> getJsonRpcWebSocketPort() {
if (isWebSocketsRpcEnabled()) {
return Optional.of(Integer.valueOf(portsProperties.getProperty("ws-rpc")));
return Optional.of(Integer.valueOf(portsProperties.getProperty(WS_RPC)));
} else {
return Optional.empty();
}
@ -345,7 +346,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
@Override
public Optional<Integer> getJsonRpcPort() {
if (isJsonRpcEnabled()) {
return Optional.of(Integer.valueOf(portsProperties.getProperty("json-rpc")));
return Optional.of(Integer.valueOf(portsProperties.getProperty(JSON_RPC)));
} else {
return Optional.empty();
}
@ -396,7 +397,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
websocketService = Optional.of((WebSocketService) web3jService);
} else {
final String url = jsonRpcBaseUrl().orElse("http://" + LOCALHOST + ":" + 8545);
final String url = jsonRpcBaseUrl().orElse(HTTP + LOCALHOST + ":" + 8545);
web3jService = new HttpService(url);
if (token != null) {
((HttpService) web3jService).addHeader("Authorization", "Bearer " + token);
@ -439,8 +440,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
baseUrl = jsonRpcBaseUrl();
port = "8545";
}
loginRequestFactory =
new LoginRequestFactory(baseUrl.orElse("http://" + LOCALHOST + ":" + port));
loginRequestFactory = new LoginRequestFactory(baseUrl.orElse(HTTP + LOCALHOST + ":" + port));
}
return loginRequestFactory;
}

Loading…
Cancel
Save