From d139dd68f78557c5a60cc75497c54a92ced5c1c0 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Mon, 19 Apr 2021 16:59:24 +0200 Subject: [PATCH] Use the loopback address for connecting to an in-process web server This may resolve the connection issues we sometimes see in GitHub Actions where the Maven process that is being tested cannot connect to the Jetty server that was just started. This closes #107 --- .../apache/maven/it/MavenIT0146InstallerSnapshotNaming.java | 4 ++-- .../org/apache/maven/it/MavenITmng2387InactiveProxyTest.java | 2 +- .../org/apache/maven/it/MavenITmng4991NonProxyHostsTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java index 0d181821cf..ea21ec9b03 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenIT0146InstallerSnapshotNaming.java @@ -86,7 +86,7 @@ public class MavenIT0146InstallerSnapshotNaming Verifier verifier = newVerifier( testDir.getAbsolutePath() ); Properties properties = verifier.newDefaultFilterProperties(); - properties.setProperty( "@host@", InetAddress.getLocalHost().getCanonicalHostName() ); + properties.setProperty( "@host@", InetAddress.getLoopbackAddress().getCanonicalHostName() ); properties.setProperty( "@port@", Integer.toString( port ) ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", properties ); @@ -125,7 +125,7 @@ public class MavenIT0146InstallerSnapshotNaming verifier = newVerifier( testDir.getAbsolutePath() ); Properties properties = verifier.newDefaultFilterProperties(); - properties.setProperty( "@host@", InetAddress.getLocalHost().getCanonicalHostName() ); + properties.setProperty( "@host@", InetAddress.getLoopbackAddress().getCanonicalHostName() ); properties.setProperty( "@port@", Integer.toString( port ) ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", properties ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2387InactiveProxyTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2387InactiveProxyTest.java index e5ed71e4a3..50de0a8f1d 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2387InactiveProxyTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2387InactiveProxyTest.java @@ -119,7 +119,7 @@ public class MavenITmng2387InactiveProxyTest Verifier verifier = newVerifier( testDir.getAbsolutePath() ); Properties properties = verifier.newDefaultFilterProperties(); - properties.setProperty( "@host@", InetAddress.getLocalHost().getCanonicalHostName() ); + properties.setProperty( "@host@", InetAddress.getLoopbackAddress().getCanonicalHostName() ); properties.setProperty( "@port@", Integer.toString( port ) ); properties.setProperty( "@proxyPort@", Integer.toString( proxyPort ) ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", properties ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4991NonProxyHostsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4991NonProxyHostsTest.java index 47a4ad16e7..66d6ac27d0 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4991NonProxyHostsTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4991NonProxyHostsTest.java @@ -93,7 +93,7 @@ public class MavenITmng4991NonProxyHostsTest filterProps.setProperty( "@port@", Integer.toString( port ) ); int proxyPort = ( (NetworkConnector) proxy.getConnectors()[0] ).getLocalPort(); filterProps.setProperty( "@proxyPort@", Integer.toString( proxyPort ) ); - filterProps.setProperty( "@localhost@", InetAddress.getLocalHost().getCanonicalHostName() ); + filterProps.setProperty( "@localhost@", InetAddress.getLoopbackAddress().getCanonicalHostName() ); verifier.filterFile( "settings-template.xml", "settings.xml", "UTF-8", filterProps ); verifier.addCliOption( "-s" ); verifier.addCliOption( "settings.xml" );