Fix deprecation warnings (#596)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Adrian Sutton 6 years ago committed by GitHub
parent 4f64725411
commit 89dbba4f97
  1. 15
      ethereum/jsonrpc/src/main/java/tech/pegasys/pantheon/ethereum/jsonrpc/JsonRpcHttpService.java
  2. 3
      ethereum/jsonrpc/src/test/java/tech/pegasys/pantheon/ethereum/jsonrpc/websocket/WebSocketServiceTest.java
  3. 2
      metrics/src/main/java/tech/pegasys/pantheon/metrics/prometheus/MetricsHttpService.java

@ -33,7 +33,6 @@ import tech.pegasys.pantheon.metrics.OperationTimer;
import tech.pegasys.pantheon.metrics.OperationTimer.TimingContext;
import tech.pegasys.pantheon.util.NetworkUtility;
import java.net.BindException;
import java.net.InetSocketAddress;
import java.net.SocketException;
import java.nio.file.Path;
@ -143,7 +142,7 @@ public class JsonRpcHttpService {
final CompletableFuture<?> resultFuture = new CompletableFuture<>();
httpServer
.requestHandler(router::accept)
.requestHandler(router)
.listen(
res -> {
if (!res.failed()) {
@ -156,7 +155,7 @@ public class JsonRpcHttpService {
}
httpServer = null;
final Throwable cause = res.cause();
if (cause instanceof BindException || cause instanceof SocketException) {
if (cause instanceof SocketException) {
resultFuture.completeExceptionally(
new JsonRpcServiceException(
String.format(
@ -172,7 +171,7 @@ public class JsonRpcHttpService {
private Handler<RoutingContext> checkWhitelistHostHeader() {
return event -> {
Optional<String> hostHeader = getAndValidateHostHeader(event);
final Optional<String> hostHeader = getAndValidateHostHeader(event);
if (config.getHostsWhitelist().contains("*")
|| (hostHeader.isPresent() && hostIsInWhitelist(hostHeader))) {
event.next();
@ -187,8 +186,8 @@ public class JsonRpcHttpService {
}
private Optional<String> getAndValidateHostHeader(final RoutingContext event) {
Iterable<String> splitHostHeader = Splitter.on(':').split(event.request().host());
long hostPieces = stream(splitHostHeader).count();
final Iterable<String> splitHostHeader = Splitter.on(':').split(event.request().host());
final long hostPieces = stream(splitHostHeader).count();
if (hostPieces > 1) {
// If the host contains a colon, verify the host is correctly formed - host [ ":" port ]
if (hostPieces > 2 || !Iterables.get(splitHostHeader, 1).matches("\\d{1,5}+")) {
@ -351,7 +350,7 @@ public class JsonRpcHttpService {
.list()
.stream()
.map(JsonRpcResponse.class::cast)
.filter(r -> isNonEmptyResponses(r))
.filter(this::isNonEmptyResponses)
.toArray(JsonRpcResponse[]::new);
routingContext.response().end(Json.encode(completed));
@ -385,7 +384,7 @@ public class JsonRpcHttpService {
}
// Generate response
try (final TimingContext context = requestTimer.labels(request.getMethod()).startTimer()) {
try (final TimingContext ignored = requestTimer.labels(request.getMethod()).startTimer()) {
return method.response(request);
} catch (final InvalidJsonRpcParameters e) {
LOG.debug(e);

@ -65,7 +65,7 @@ public class WebSocketServiceTest {
websocketConfiguration.setPort(websocketService.socketAddress().getPort());
HttpClientOptions httpClientOptions =
final HttpClientOptions httpClientOptions =
new HttpClientOptions()
.setDefaultHost(websocketConfiguration.getHost())
.setDefaultPort(websocketConfiguration.getPort());
@ -135,6 +135,7 @@ public class WebSocketServiceTest {
async.awaitSuccess(VERTX_AWAIT_TIMEOUT_MILLIS);
}
@SuppressWarnings("deprecation") // No alternative available in vertx 3.
@Test
public void websocketServiceMustReturnErrorOnHttpRequest(final TestContext context) {
final Async async = context.async();

@ -98,7 +98,7 @@ public class MetricsHttpService {
final CompletableFuture<?> resultFuture = new CompletableFuture<>();
httpServer
.requestHandler(router::accept)
.requestHandler(router)
.listen(
res -> {
if (!res.failed()) {

Loading…
Cancel
Save