postgresql-jdbc.git / summary / log / commit / refs
commit 68da950e7f4798a854825d2f3bb6cb3e48b3a25d
Author: Craig Ringer <ringerc@ringerc.id.au>
Date: Thu Sep 20 06:02:18 2012 +0000
Allow testing to continue when local host name doesn't resolve
It seems to be a common and default configuration on some Linux systems
for the local hostname not to resolve to the loopback IP address. This
causes testTimeoutOccurs(org.postgresql.test.jdbc2.LoginTimeoutTest)
to fail. I'm seeing this on Fedora 17 among others.
While it's best to fix such systems, not causing an easily avoided
and spurious failure in PgJDBC's test suite is probably worthwhile.
Spit out a warning and continue.
.gitignore | 1 +
org/postgresql/test/jdbc2/LoginTimeoutTest.java | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 931ed6c5..9cd9fb30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
.externalToolBuilders
build
jars
+.*.swp
diff --git a/org/postgresql/test/jdbc2/LoginTimeoutTest.java b/org/postgresql/test/jdbc2/LoginTimeoutTest.java
index 58dddcaf..e1b329aa 100644
--- a/org/postgresql/test/jdbc2/LoginTimeoutTest.java
+++ b/org/postgresql/test/jdbc2/LoginTimeoutTest.java
@@ -80,7 +80,14 @@ public class LoginTimeoutTest extends TestCase
private static class TimeoutHelper implements Runnable {
TimeoutHelper() throws IOException {
- this.listenSocket = new ServerSocket(0, 1, InetAddress.getLocalHost());
+ InetAddress localAddr;
+ try {
+ localAddr = InetAddress.getLocalHost();
+ } catch (java.net.UnknownHostException ex) {
+ System.err.println("WARNING: Could not resolve local host name, trying 'localhost'. " + ex);
+ localAddr = InetAddress.getByName("localhost");
+ }
+ this.listenSocket = new ServerSocket(0, 1, localAddr);
}
String getHost() {
[parent: db0d6b0fb018]