You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by sy...@apache.org on 2022/06/01 15:35:23 UTC

[zookeeper] branch branch-3.7 updated: ZOOKEEPER-4551: Do not log spammy stacktrace when a client closes its connection

This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.7
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/branch-3.7 by this push:
     new 71cb76033 ZOOKEEPER-4551: Do not log spammy stacktrace when a client closes its connection
71cb76033 is described below

commit 71cb76033a0c105a83f2c54c5ef09936b11a8e52
Author: Enrico Olivelli <eo...@apache.org>
AuthorDate: Wed Jun 1 17:33:57 2022 +0200

    ZOOKEEPER-4551: Do not log spammy stacktrace when a client closes its connection
    
    Motivation:
    See more here https://issues.apache.org/jira/browse/ZOOKEEPER-4551
    
    Modifications:
    Do not log the stacktrace, just write the message at INFO level
    
    Author: Enrico Olivelli <eo...@apache.org>
    
    Reviewers: Mate Szalay-Beko <sy...@apache.org>
    
    Closes #1889 from eolivelli/fix/remove-spam-stacktrace
    
    (cherry picked from commit 7a515fee0124eea389c599995915927e49cf4c57)
    Signed-off-by: Mate Szalay-Beko <sy...@apache.com>
---
 .../main/java/org/apache/zookeeper/server/NIOServerCnxn.java   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxn.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxn.java
index 02cde23a9..dd62154fc 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxn.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxn.java
@@ -330,7 +330,15 @@ public class NIOServerCnxn extends ServerCnxn {
             if (k.isReadable()) {
                 int rc = sock.read(incomingBuffer);
                 if (rc < 0) {
-                    handleFailedRead();
+                    try {
+                        handleFailedRead();
+                    } catch (EndOfStreamException e) {
+                        // no stacktrace. this case is very common, and it is usually not a problem.
+                        LOG.info("{}", e.getMessage());
+                        // expecting close to log session closure
+                        close(e.getReason());
+                        return;
+                    }
                 }
                 if (incomingBuffer.remaining() == 0) {
                     boolean isPayload;