zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject zookeeper git commit: ZOOKEEPER-2664: ClientPortBindTest#testBindByAddress may fail due to "No such device" exception
Date Sat, 14 Jan 2017 05:32:24 GMT
Repository: zookeeper
Updated Branches:
  refs/heads/master 8773ecb78 -> 42c75b5f2


ZOOKEEPER-2664: ClientPortBindTest#testBindByAddress may fail due to "No such device" exception

The following stack trace was observed intermittently:
```
Stacktrace

java.net.SocketException: No such device
	at java.net.NetworkInterface.isLoopback0(Native Method)
	at java.net.NetworkInterface.isLoopback(NetworkInterface.java:390)
	at org.apache.zookeeper.test.ClientPortBindTest.testBindByAddress(ClientPortBindTest.java:61)
	at org.apache.zookeeper.JUnit4ZKTestRunner$LoggedInvokeMethod.evaluate(JUnit4ZKTestRunner.java:52)
Standard Output
```
Proposed fix is to catch exception from isLoopback() call and skip the test in that case.

Author: tedyu <yuzhihong@gmail.com>

Reviewers: Edward Ribeiro <edward.ribeiro@gmail.com>, Michael Han <hanm@apache.org>

Closes #149 from tedyu/master


Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/42c75b5f
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/42c75b5f
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/42c75b5f

Branch: refs/heads/master
Commit: 42c75b5f2457f8ea5b4106ce5dc1c34c330361c0
Parents: 8773ecb
Author: tedyu <yuzhihong@gmail.com>
Authored: Fri Jan 13 21:32:15 2017 -0800
Committer: Michael Han <hanm@apache.org>
Committed: Fri Jan 13 21:32:15 2017 -0800

----------------------------------------------------------------------
 .../apache/zookeeper/test/ClientPortBindTest.java    | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zookeeper/blob/42c75b5f/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
----------------------------------------------------------------------
diff --git a/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java b/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
index b52cb11..100d2a0 100644
--- a/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
+++ b/src/java/test/org/apache/zookeeper/test/ClientPortBindTest.java
@@ -24,6 +24,7 @@ import java.io.File;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.NetworkInterface;
+import java.net.SocketException;
 import java.util.Enumeration;
 
 import org.slf4j.Logger;
@@ -51,15 +52,19 @@ public class ClientPortBindTest extends ZKTestCase{
         // if we have a loopback and it has an address use it
         while(intfs.hasMoreElements()) {
             NetworkInterface i = intfs.nextElement();
-            if (i.isLoopback()) {
-                Enumeration<InetAddress> addrs = i.getInetAddresses();
-                while (addrs.hasMoreElements()) {
+            try {
+                if (i.isLoopback()) {
+                  Enumeration<InetAddress> addrs = i.getInetAddresses();
+                  while (addrs.hasMoreElements()) {
                     InetAddress a = addrs.nextElement();
                     if(a.isLoopbackAddress()) {
-                        bindAddress = a.getHostAddress();
-                        break;
+                      bindAddress = a.getHostAddress();
+                      break;
                     }
+                  }
                 }
+            } catch (SocketException se) {
+                LOG.warn("Couldn't find  loopback interface: " + se.getMessage());
             }
         }
         if (bindAddress == null) {


Mime
View raw message