Przeglądaj źródła

ZOOKEEPER-597. ASyncHammerTest is failing intermittently on hudson trunk (take 4) (breed via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@886960 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 15 lat temu
rodzic
commit
5ac3e71926

+ 3 - 0
CHANGES.txt

@@ -145,6 +145,9 @@ BUGFIXES:
   ZOOKEEPER-597. ASyncHammerTest is failing intermittently on hudson trunk
   (take 3) (phunt via mahadev)
 
+  ZOOKEEPER-597. ASyncHammerTest is failing intermittently on hudson trunk
+  (take 4) (breed via mahadev)
+
 IMPROVEMENTS:
   ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to
   "socket reuse" and failure to close client (phunt via mahadev)

+ 8 - 17
src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java

@@ -71,6 +71,13 @@ public class NIOServerCnxn implements Watcher, ServerCnxn {
 
     private ConnectionBean jmxConnectionBean;
 
+    static {
+        Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            public void uncaughtException(Thread t, Throwable e) {
+                LOG.error("Thread " + t + " died", e);
+            }
+        });
+    }
 
     static public class Factory extends Thread {
         ZooKeeperServer zks;
@@ -937,8 +944,6 @@ public class NIOServerCnxn implements Watcher, ServerCnxn {
         return "NIOServerCnxn object with sock = " + sock + " and sk = " + sk;
     }
 
-    boolean closed;
-
     /*
      * (non-Javadoc)
      *
@@ -955,12 +960,6 @@ public class NIOServerCnxn implements Watcher, ServerCnxn {
         }
         jmxConnectionBean = null;
 
-        synchronized(this) {
-            if (closed) {
-                return;
-            }
-            closed = true;
-        }
         synchronized (factory.ipMap)
         {
             Set<NIOServerCnxn> s = factory.ipMap.get(sock.socket().getInetAddress());
@@ -1041,14 +1040,6 @@ public class NIOServerCnxn implements Watcher, ServerCnxn {
      */
     synchronized public void sendResponse(ReplyHeader h, Record r, String tag) {
         try {
-            if (closed) {
-                if (LOG.isTraceEnabled()) {
-                    LOG.trace("send called on closed session 0x"
-                              + Long.toHexString(sessionId)
-                              + " with record " + r);
-                }
-                return;
-            }
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             // Make space for length
             BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
@@ -1078,7 +1069,7 @@ public class NIOServerCnxn implements Watcher, ServerCnxn {
                 }
             }
          } catch(Exception e) {
-            LOG.error("Unexpected exception. Destruction averted.", e);
+            LOG.warn("Unexpected exception. Destruction averted.", e);
          }
     }