Repository: zookeeper
Updated Branches:
refs/heads/branch-3.4 88e4d9dcd -> 3271f3d03
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 <[email protected]>
Reviewers: Edward Ribeiro <[email protected]>, Michael Han
<[email protected]>
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/3271f3d0
Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/3271f3d0
Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/3271f3d0
Branch: refs/heads/branch-3.4
Commit: 3271f3d03d75c675ec1e466434eee0834cb9841a
Parents: 88e4d9d
Author: tedyu <[email protected]>
Authored: Fri Jan 13 21:32:15 2017 -0800
Committer: Michael Han <[email protected]>
Committed: Mon Jan 23 09:53:31 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/3271f3d0/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 22f9dde..d6cb1e2 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 java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -58,15 +59,19 @@ public class ClientPortBindTest extends ZKTestCase
implements Watcher {
// 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) {