Browse Source

PR 56593 XMLJUnitResultFormatter may throw NPE when Java cannot

determine hostname.  Submitted by Joel Tucci.
master
Stefan Bodewig 11 years ago
parent
commit
a6b49f948d
4 changed files with 14 additions and 2 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +6
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java

+ 1
- 0
CONTRIBUTORS View File

@@ -182,6 +182,7 @@ Jesse Glick
Jesse Stockall Jesse Stockall
Jim Allers Jim Allers
Joerg Wassmer Joerg Wassmer
Joel Tucci
Joey Richey Joey Richey
Johann Herunter Johann Herunter
John Elion John Elion


+ 3
- 0
WHATSNEW View File

@@ -14,6 +14,9 @@ Fixed bugs:
* TarArchiveInputStream could throw IOException when reading PAX * TarArchiveInputStream could throw IOException when reading PAX
headers from a "slow" InputStream. headers from a "slow" InputStream.


* XMLJunitResultFormatter could throw NullPointerException if Java
cannot determine the local hostname.
Bugzilla Report 56593


Other changes: Other changes:
-------------- --------------


+ 4
- 0
contributors.xml View File

@@ -751,6 +751,10 @@
<first>Joerg</first> <first>Joerg</first>
<last>Wassmer</last> <last>Wassmer</last>
</name> </name>
<name>
<first>Joel</first>
<last>Tucci</last>
</name>
<name> <name>
<first>Joey</first> <first>Joey</first>
<last>Richey</last> <last>Richey</last>


+ 6
- 2
src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java View File

@@ -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 * @return the name of the local host, or "localhost" if we cannot work it out
*/ */
private String getHostname() { private String getHostname() {
String hostname = "localhost";
try { try {
return InetAddress.getLocalHost().getHostName();
InetAddress localHost = InetAddress.getLocalHost();
if (localHost != null) {
hostname = localHost.getHostName();
}
} catch (UnknownHostException e) { } catch (UnknownHostException e) {
return "localhost";
} }
return hostname;
} }


/** /**


Loading…
Cancel
Save