From 38f50edfa161a304fe5b956216c6259ba78da70f Mon Sep 17 00:00:00 2001 From: AnuGayan Date: Fri, 28 Jun 2024 07:59:11 +0530 Subject: [PATCH] Make connection reset error log a debug log From JDK 17 onword, the Connection Reset by peer error log has been replaced by Connection Reset. Hence contains check has to be changed to check the string as in this commit --- .../transport/http/conn/LoggingNHttpServiceHandler.java | 2 +- .../org/apache/synapse/transport/nhttp/ServerHandler.java | 4 ++-- .../org/apache/synapse/transport/passthru/SourceHandler.java | 2 +- .../org/apache/synapse/transport/passthru/TargetHandler.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/http/conn/LoggingNHttpServiceHandler.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/http/conn/LoggingNHttpServiceHandler.java index 8a9665b095..bf5990fe4f 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/http/conn/LoggingNHttpServiceHandler.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/http/conn/LoggingNHttpServiceHandler.java @@ -70,7 +70,7 @@ public void exception(final NHttpServerConnection conn, final Exception ex) { msg = ""; } if (ex instanceof ConnectionClosedException || - msg.contains("Connection reset by peer") || + msg.contains("Connection reset") || msg.contains("forcibly closed")) { if (this.log.isDebugEnabled()) { this.log.debug(conn + ": " + msg + diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerHandler.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerHandler.java index b9c2fb8984..9551b3f762 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerHandler.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/nhttp/ServerHandler.java @@ -619,7 +619,7 @@ public void exception(NHttpServerConnection conn, Exception e) { commitResponseHideExceptions(conn, response); } catch (Exception ignore) {} } else if (e instanceof ConnectionClosedException || (e.getMessage() != null && - (e.getMessage().contains("Connection reset by peer") || + (e.getMessage().contains("Connection reset") || e.getMessage().contains("forcibly closed")))) { if (log.isDebugEnabled()) { errMsg = "I/O error (Probably the keepalive connection " + @@ -658,7 +658,7 @@ public void exception(NHttpServerConnection conn, IOException e) { String errMsg = "I/O error : " + e.getMessage(); if (e instanceof ConnectionClosedException || (e.getMessage() != null && - (e.getMessage().contains("Connection reset by peer") || + (e.getMessage().contains("Connection reset") || e.getMessage().contains("forcibly closed")))) { if (log.isDebugEnabled()) { errMsg = "I/O error (Probably the keepalive connection " + diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java index a91d282fbb..64f1f33f70 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/SourceHandler.java @@ -645,7 +645,7 @@ public void logIOException(NHttpServerConnection conn, IOException e) { return; } if (e instanceof ConnectionClosedException || (e.getMessage() != null && ( - e.getMessage().toLowerCase().contains("connection reset by peer") || + e.getMessage().toLowerCase().contains("connection reset") || e.getMessage().toLowerCase().contains("forcibly closed")))) { if (log.isDebugEnabled()) { log.debug(conn + ": I/O error (Probably the keepalive connection " diff --git a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java index b7319cce8f..b7bc99cc97 100644 --- a/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java +++ b/modules/transports/core/nhttp/src/main/java/org/apache/synapse/transport/passthru/TargetHandler.java @@ -840,7 +840,7 @@ private void logIOException(NHttpClientConnection conn, IOException e) { String message = getErrorMessage("I/O error : " + e.getMessage(), conn); if (e.getMessage() != null && (e instanceof ConnectionClosedException - || e.getMessage().toLowerCase().contains("connection reset by peer") + || e.getMessage().toLowerCase().contains("connection reset") || e.getMessage().toLowerCase().contains("forcibly closed"))) { if (log.isDebugEnabled()) { log.debug(conn + ": I/O error (Probably the keep-alive connection "