浏览代码

ZOOKEEPER-1629. testTransactionLogCorruption occasionally fails. (shralex via camille)

git-svn-id: https://svn.apache.org/repos/asf/zookeeper/trunk@1503101 13f79535-47bb-0310-9956-ffa450edef68
Camille Fournier 12 年之前
父节点
当前提交
c0051fd836
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      src/java/test/org/apache/zookeeper/server/util/PortForwarder.java

+ 11 - 9
src/java/test/org/apache/zookeeper/server/util/PortForwarder.java

@@ -211,24 +211,26 @@ public class PortForwarder extends Thread {
                             sock.getInputStream(), target.getOutputStream()));
                     this.workers.execute(new PortForwardWorker(target, sock,
                             target.getInputStream(), sock.getOutputStream()));
-                } catch (SocketTimeoutException e) {
-                    LOG.warn("socket timed out local:" + sock.getLocalPort()
-                            + " from:" + sock.getPort()
+                } catch (SocketTimeoutException e) {               	
+                    LOG.warn("socket timed out local:" 
+                            + (sock != null ? sock.getLocalPort(): "")
+                            + " from:" + (sock != null ? sock.getPort(): "")
                             + " to:" + to, e);
                 } catch (ConnectException e) {
-                    LOG.warn("connection exception local:" + sock.getLocalPort()
-                            + " from:" + sock.getPort()
+                    LOG.warn("connection exception local:"
+                            + (sock != null ? sock.getLocalPort(): "")
+                            + " from:" + (sock != null ? sock.getPort(): "")
                             + " to:" + to, e);
                     sock.close();
                 } catch (IOException e) {
                     if (!"Socket closed".equals(e.getMessage())) {
-                        LOG.warn("unexpected exception local:" + sock.getLocalPort()
-                            + " from:" + sock.getPort()
-                            + " to:" + to, e);
+                        LOG.warn("unexpected exception local:" 
+                        		+ (sock != null ? sock.getLocalPort(): "")
+                                + " from:" + (sock != null ? sock.getPort(): "")
+                                + " to:" + to, e);
                         throw e;
                     }
                 }
-
             }
         } catch (IOException e) {
             LOG.error("Unexpected exception to:" + to, e);