From cb9c34759d1602b0f651bad150cad2eae3fdec1a Mon Sep 17 00:00:00 2001 From: liubao68 Date: Mon, 15 Apr 2024 09:51:21 +0800 Subject: [PATCH] [SCB-2872]Fix idle timeout for read and write is not properly set problem (#4297) --- .../vertx/client/http/HttpClientOptionsSPI.java | 2 -- .../transport/rest/vertx/RestServerVerticle.java | 11 ++--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientOptionsSPI.java b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientOptionsSPI.java index 1545081a576..78a12d099cc 100644 --- a/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientOptionsSPI.java +++ b/foundations/foundation-vertx/src/main/java/org/apache/servicecomb/foundation/vertx/client/http/HttpClientOptionsSPI.java @@ -103,8 +103,6 @@ static HttpClientOptions createHttpClientOptions(HttpClientOptionsSPI spi) { httpClientOptions.setProtocolVersion(spi.getHttpVersion()); httpClientOptions.setConnectTimeout(spi.getConnectTimeoutInMillis()); httpClientOptions.setIdleTimeout(spi.getIdleTimeoutInSeconds()); - httpClientOptions.setReadIdleTimeout(spi.getIdleTimeoutInSeconds()); - httpClientOptions.setWriteIdleTimeout(spi.getIdleTimeoutInSeconds()); httpClientOptions.setTryUseCompression(spi.isTryUseCompression()); httpClientOptions.setMaxWaitQueueSize(spi.getMaxWaitQueueSize()); httpClientOptions.setMaxPoolSize(spi.getMaxPoolSize()); diff --git a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java index 93920dbc14b..c72e50435cc 100644 --- a/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java +++ b/transports/transport-rest/transport-rest-vertx/src/main/java/org/apache/servicecomb/transport/rest/vertx/RestServerVerticle.java @@ -67,14 +67,12 @@ public class RestServerVerticle extends AbstractVerticle { private static final String SSL_KEY = "rest.provider"; - private Endpoint endpoint; - private URIEndpointObject endpointObject; @Override public void init(Vertx vertx, Context context) { super.init(vertx, context); - this.endpoint = (Endpoint) context.config().getValue(AbstractTransport.ENDPOINT_KEY); + Endpoint endpoint = (Endpoint) context.config().getValue(AbstractTransport.ENDPOINT_KEY); this.endpointObject = (URIEndpointObject) endpoint.getAddress(); } @@ -137,9 +135,8 @@ void mountGlobalRestFailureHandler(Router mainRouter) { return; } HttpServerResponse response = ctx.response(); - if (ctx.failure() instanceof InvocationException) { + if (ctx.failure() instanceof InvocationException exception) { // ServiceComb defined exception - InvocationException exception = (InvocationException) ctx.failure(); response.setStatusCode(exception.getStatusCode()); response.setStatusMessage(exception.getReasonPhrase()); response.end(exception.getErrorData().toString()); @@ -270,8 +267,6 @@ private HttpServerOptions createDefaultHttpServerOptions() { serverOptions.setUseAlpn(TransportConfig.getUseAlpn()) .setHttp2ConnectionWindowSize(TransportConfig.getHttp2ConnectionWindowSize()) .setIdleTimeout(TransportConfig.getHttp2ConnectionIdleTimeoutInSeconds()) - .setReadIdleTimeout(TransportConfig.getHttp2ConnectionIdleTimeoutInSeconds()) - .setWriteIdleTimeout(TransportConfig.getHttp2ConnectionIdleTimeoutInSeconds()) .setInitialSettings(new Http2Settings().setPushEnabled(TransportConfig.getPushEnabled()) .setMaxConcurrentStreams(TransportConfig.getMaxConcurrentStreams()) .setHeaderTableSize(TransportConfig.getHttp2HeaderTableSize()) @@ -281,8 +276,6 @@ private HttpServerOptions createDefaultHttpServerOptions() { ); } else { serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds()); - serverOptions.setReadIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds()); - serverOptions.setWriteIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds()); } if (endpointObject.isSslEnabled()) { SSLOptionFactory factory =