diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index a533fb8b9..4a10c42b4 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -182,6 +182,7 @@ Jesse Glick
Jesse Stockall
Jim Allers
Joerg Wassmer
+Joel Tucci
Joey Richey
Johann Herunter
John Elion
diff --git a/WHATSNEW b/WHATSNEW
index ab0212420..6ebed1eca 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -14,6 +14,9 @@ Fixed bugs:
* TarArchiveInputStream could throw IOException when reading PAX
headers from a "slow" InputStream.
+ * XMLJunitResultFormatter could throw NullPointerException if Java
+ cannot determine the local hostname.
+ Bugzilla Report 56593
Other changes:
--------------
diff --git a/contributors.xml b/contributors.xml
index 488d784e4..a86950aff 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -751,6 +751,10 @@
Joerg
Wassmer
+
+ Joel
+ Tucci
+
Joey
Richey
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
index 4ff3ab1cd..7f064f963 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java
@@ -161,11 +161,15 @@ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstan
* @return the name of the local host, or "localhost" if we cannot work it out
*/
private String getHostname() {
+ String hostname = "localhost";
try {
- return InetAddress.getLocalHost().getHostName();
+ InetAddress localHost = InetAddress.getLocalHost();
+ if (localHost != null) {
+ hostname = localHost.getHostName();
+ }
} catch (UnknownHostException e) {
- return "localhost";
}
+ return hostname;
}
/**