You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/06/29 13:30:40 UTC
(commons-vfs) branch master updated: Replace "localhost" with InetAddress.getLocalHost().getCanonicalHostName()
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new 939dc9d0 Replace "localhost" with InetAddress.getLocalHost().getCanonicalHostName()
939dc9d0 is described below
commit 939dc9d0cdb43afb929f39df835dce830ed57740
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jun 29 09:30:36 2024 -0400
Replace "localhost" with
InetAddress.getLocalHost().getCanonicalHostName()
The next versions of Apache HttpComponents Core and Client are stricter
---
.../org/apache/commons/vfs2/AbstractProviderTestConfig.java | 11 +++++++++++
.../commons/vfs2/provider/http/HttpProviderTestCase.java | 3 +--
.../commons/vfs2/provider/http4/Http4ProviderTestCase.java | 2 +-
.../commons/vfs2/provider/http5/Http5ProviderTestCase.java | 3 +--
.../commons/vfs2/provider/url/UrlProviderHttpTestCase.java | 3 +--
5 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/AbstractProviderTestConfig.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/AbstractProviderTestConfig.java
index 888f9d45..78d23006 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/AbstractProviderTestConfig.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/AbstractProviderTestConfig.java
@@ -16,6 +16,9 @@
*/
package org.apache.commons.vfs2;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
import org.apache.commons.vfs2.cache.SoftRefFilesCache;
import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
@@ -30,6 +33,14 @@ public abstract class AbstractProviderTestConfig extends AbstractProviderTestCas
public static final String MIME_TYPE_APPLICATION_ZIP = "application/zip";
+ public static String getLocalCanonicalHostName() throws UnknownHostException {
+ return InetAddress.getLocalHost().getCanonicalHostName();
+ }
+
+ public static String getLocalHostUriString(final String scheme, final int socketPort) throws UnknownHostException {
+ return scheme + "://" + getLocalCanonicalHostName() + ":" + socketPort;
+ }
+
private FilesCache filesCache;
/**
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java
index 81028274..150ea48b 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http/HttpProviderTestCase.java
@@ -61,8 +61,7 @@ public class HttpProviderTestCase extends AbstractProviderTestConfig {
*/
private static void setUpClass() throws Exception {
server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000);
- final int socketPort = server.getPort();
- connectionUri = "http://localhost:" + socketPort;
+ connectionUri = getLocalHostUriString("http", server.getPort());
}
/**
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
index 5ad353ea..938e5612 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http4/Http4ProviderTestCase.java
@@ -61,7 +61,7 @@ public class Http4ProviderTestCase extends AbstractProviderTestConfig {
private static void setUpClass() throws Exception {
server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000);
final int socketPort = server.getPort();
- connectionUri = "http4://localhost:" + socketPort;
+ connectionUri = getLocalHostUriString("http4", server.getPort());
}
/**
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java
index abc18e6b..957a6d7a 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/http5/Http5ProviderTestCase.java
@@ -60,8 +60,7 @@ public class Http5ProviderTestCase extends AbstractProviderTestConfig {
*/
private static void setUpClass() throws Exception {
server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000);
- final int socketPort = server.getPort();
- connectionUri = "http5://localhost:" + socketPort;
+ connectionUri = getLocalHostUriString("http5", server.getPort());
}
/**
diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java
index 78863c48..c4a7b597 100644
--- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java
+++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/provider/url/UrlProviderHttpTestCase.java
@@ -56,8 +56,7 @@ public class UrlProviderHttpTestCase extends AbstractProviderTestConfig {
*/
private static void setUpClass() throws Exception {
server = NHttpFileServer.start(0, new File(getTestDirectory()), 5000);
- final int socketPort = server.getPort();
- connectionUri = "http://localhost:" + socketPort;
+ connectionUri = getLocalHostUriString("http", server.getPort());
}
public static Test suite() throws Exception {