From c3a1334de2f8e45ae92a6de1a5f3d853bb21d4a4 Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Tue, 31 Dec 2024 14:05:13 +0200 Subject: [PATCH] small nits --- .../rpc/core/Eth2IncomingRequestHandler.java | 8 ++++---- .../rpc/core/Eth2OutgoingRequestHandler.java | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2IncomingRequestHandler.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2IncomingRequestHandler.java index fd70ec3e0b6..9d3c3fdcb83 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2IncomingRequestHandler.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2IncomingRequestHandler.java @@ -121,9 +121,8 @@ private void handleRequest( private void ensureRequestReceivedWithinTimeLimit(final RpcStream stream) { asyncRunner - .getDelayedFuture(RECEIVE_INCOMING_REQUEST_TIMEOUT) - .thenAccept( - (__) -> { + .runAfterDelay( + () -> { if (!requestHandled.get()) { LOG.debug( "Failed to receive incoming request data within {} sec for protocol {}. Close stream.", @@ -131,7 +130,8 @@ private void ensureRequestReceivedWithinTimeLimit(final RpcStream stream) { protocolId); stream.closeAbruptly().ifExceptionGetsHereRaiseABug(); } - }) + }, + RECEIVE_INCOMING_REQUEST_TIMEOUT) .ifExceptionGetsHereRaiseABug(); } diff --git a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2OutgoingRequestHandler.java b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2OutgoingRequestHandler.java index 36b66e33f15..914b015b352 100644 --- a/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2OutgoingRequestHandler.java +++ b/networking/eth2/src/main/java/tech/pegasys/teku/networking/eth2/rpc/core/Eth2OutgoingRequestHandler.java @@ -255,9 +255,8 @@ private void ensureNextResponseChunkArrivesInTime( final int previousResponseCount, final AtomicInteger currentResponseCount) { timeoutRunner - .getDelayedFuture(RESPONSE_CHUNK_ARRIVAL_TIMEOUT) - .thenAccept( - (__) -> { + .runAfterDelay( + () -> { if (previousResponseCount == currentResponseCount.get()) { abortRequest( stream, @@ -265,22 +264,23 @@ private void ensureNextResponseChunkArrivesInTime( "Timed out waiting for response chunk " + previousResponseCount, RESPONSE_CHUNK_ARRIVAL_TIMEOUT)); } - }) + }, + RESPONSE_CHUNK_ARRIVAL_TIMEOUT) .ifExceptionGetsHereRaiseABug(); } private void ensureReadCompleteArrivesInTime(final RpcStream stream) { timeoutRunner - .getDelayedFuture(READ_COMPLETE_TIMEOUT) - .thenAccept( - (__) -> { + .runAfterDelay( + () -> { if (!(state.get() == READ_COMPLETE || state.get() == CLOSED)) { abortRequest( stream, new RpcTimeoutException( "Timed out waiting for read channel close", READ_COMPLETE_TIMEOUT)); } - }) + }, + READ_COMPLETE_TIMEOUT) .ifExceptionGetsHereRaiseABug(); }