This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 127e85e  Fix test failure - don't try and connect to an i/f that is 
down
127e85e is described below

commit 127e85e7b3989701ced95ccc1f4793112b92e38f
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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to