You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/10/01 13:58:50 UTC
[tomcat] branch 9.0.x updated: Fix test failure - don't try and
connect to an i/f that is down
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 1dc46d4 Fix test failure - don't try and connect to an i/f that is down
1dc46d4 is described below
commit 1dc46d49bfe19732ef9544e20c6354f6a2a6bd66
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 1 14:15:49 2020 +0100
Fix test failure - don't try and connect to an i/f that is down
---
.../jni/TestSocketServerAnyLocalAddress.java | 30 ++++++++++++----------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java b/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
index 0023db2..c983608 100644
--- a/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
+++ b/test/org/apache/tomcat/jni/TestSocketServerAnyLocalAddress.java
@@ -182,21 +182,23 @@ public class TestSocketServerAnyLocalAddress extends AbstractJniTest {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
- Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
- while (inetAddresses.hasMoreElements()) {
- InetAddress inetAddress = inetAddresses.nextElement();
- if (localAddress.getAddress().getClass().isAssignableFrom(inetAddress.getClass())) {
- if (inetAddress.isLoopbackAddress()) {
- if (loopbackConnectAddress == null) {
- loopbackConnectAddress = inetAddress;
+ if (networkInterface.isUp()) {
+ Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
+ while (inetAddresses.hasMoreElements()) {
+ InetAddress inetAddress = inetAddresses.nextElement();
+ if (localAddress.getAddress().getClass().isAssignableFrom(inetAddress.getClass())) {
+ if (inetAddress.isLoopbackAddress()) {
+ if (loopbackConnectAddress == null) {
+ loopbackConnectAddress = inetAddress;
+ }
+ } else if (inetAddress.isLinkLocalAddress()) {
+ if (linkLocalConnectAddress == null) {
+ linkLocalConnectAddress = inetAddress;
+ }
+ } else {
+ // Use a non-link local, non-loop back address by default
+ return new InetSocketAddress(inetAddress, localAddress.getPort());
}
- } else if (inetAddress.isLinkLocalAddress()) {
- if (linkLocalConnectAddress == null) {
- linkLocalConnectAddress = inetAddress;
- }
- } else {
- // Use a non-link local, non-loop back address by default
- return new InetSocketAddress(inetAddress, localAddress.getPort());
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org