This is an automated email from the ASF dual-hosted git repository.
dsoumis pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 25139f9ff9 Stabilize TestStartupIPv6Connectors IPv6 selection
25139f9ff9 is described below
commit 25139f9ff9f084cc5829a75c63277b2b27636f1f
Author: Dimitris Soumis <[email protected]>
AuthorDate: Wed Nov 12 13:38:55 2025 +0200
Stabilize TestStartupIPv6Connectors IPv6 selection
---
.../startup/TestStartupIPv6Connectors.java | 47 ++++++++++++++++++----
1 file changed, 39 insertions(+), 8 deletions(-)
diff --git a/test/org/apache/catalina/startup/TestStartupIPv6Connectors.java
b/test/org/apache/catalina/startup/TestStartupIPv6Connectors.java
index 2212e396e4..14e7fc30db 100644
--- a/test/org/apache/catalina/startup/TestStartupIPv6Connectors.java
+++ b/test/org/apache/catalina/startup/TestStartupIPv6Connectors.java
@@ -64,28 +64,59 @@ public class TestStartupIPv6Connectors extends
TomcatBaseTest {
@BeforeClass
public static void initializeTestIpv6Addresses() throws Exception {
+ Inet6Address possibleLinkLocalLoopback = null;
+ Inet6Address possibleLinkLocalOnGlobal = null;
+ Inet6Address possibleLinkLocalAny = null;
+
Enumeration<NetworkInterface> interfaces =
NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface interf = interfaces.nextElement();
- Enumeration<InetAddress> addresses = interf.getInetAddresses();
- if (interf.isPointToPoint()) {
+ if (!interf.isUp() || interf.isVirtual() ||
interf.isPointToPoint() || !interf.supportsMulticast()) {
continue;
}
+ Enumeration<InetAddress> addresses = interf.getInetAddresses();
+ boolean globalOnInterface = false;
while (addresses.hasMoreElements()) {
InetAddress address = addresses.nextElement();
if (address instanceof Inet6Address inet6Address) {
- if (inet6Address.isLinkLocalAddress()) {
- linklocalAddress = inet6Address.getHostAddress();
- }
if (!inet6Address.isAnyLocalAddress() &&
!inet6Address.isLoopbackAddress() && !inet6Address.isLinkLocalAddress() &&
!inet6Address.isMulticastAddress()) {
- globalAddress = inet6Address.getHostAddress();
+ globalOnInterface = true;
+ if (!interf.isLoopback()) {
+ globalAddress = inet6Address.getHostAddress();
+ break;
+ }
}
- if (linklocalAddress != null && globalAddress != null) {
- return;
+ }
+ }
+
+ // Second pass to get link-local results with specific order
+ addresses = interf.getInetAddresses();
+ while (addresses.hasMoreElements()) {
+ InetAddress address = addresses.nextElement();
+ if (address instanceof Inet6Address inet6Address) {
+ if (inet6Address.isLinkLocalAddress()) {
+ if (interf.isLoopback()) {
+ // Best option for mac
+ possibleLinkLocalLoopback = inet6Address;
+ } else if (globalOnInterface &&
possibleLinkLocalOnGlobal == null) {
+ // link-local on an interface that also has a
global IPv6 (e.g. en0)
+ possibleLinkLocalOnGlobal = inet6Address;
+ } else if (possibleLinkLocalAny == null) {
+ possibleLinkLocalAny = inet6Address;
+ }
}
}
}
}
+
+ if (possibleLinkLocalLoopback != null) {
+ linklocalAddress = possibleLinkLocalLoopback.getHostAddress();
+ } else if (possibleLinkLocalOnGlobal != null) {
+ linklocalAddress = possibleLinkLocalOnGlobal.getHostAddress();
+ } else if (possibleLinkLocalAny != null) {
+ linklocalAddress = possibleLinkLocalAny.getHostAddress();
+ }
+
}
private void assertHttpOkOnAddress(String address) throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]