Browse Source

fix nasty NPE in <junit> when the user doesn't specify a nested <classpath>.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272471 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
d1503ea657
1 changed files with 13 additions and 8 deletions
  1. +13
    -8
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 13
- 8
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -722,14 +722,17 @@ public class JUnitTask extends Task {
try { try {
log("Using System properties " + System.getProperties(), log("Using System properties " + System.getProperties(),
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
Path classpath = (Path) commandline.getClasspath().clone();
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses + " to CLASSPATH",
Project.MSG_VERBOSE);
classpath.append(antRuntimeClasses);
}

Path userClasspath = commandline.getClasspath();
Path classpath = userClasspath == null
? null
: (Path) userClasspath.clone();
if (classpath != null) { if (classpath != null) {
if (includeAntRuntime) {
log("Implicitly adding " + antRuntimeClasses
+ " to CLASSPATH", Project.MSG_VERBOSE);
classpath.append(antRuntimeClasses);
}

cl = new AntClassLoader(null, project, classpath, false); cl = new AntClassLoader(null, project, classpath, false);
log("Using CLASSPATH " + cl.getClasspath(), log("Using CLASSPATH " + cl.getClasspath(),
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
@@ -772,7 +775,9 @@ public class JUnitTask extends Task {
if (sysProperties != null) { if (sysProperties != null) {
sysProperties.restoreSystem(); sysProperties.restoreSystem();
} }
cl.resetThreadContextLoader();
if (cl != null) {
cl.resetThreadContextLoader();
}
} }
} }




Loading…
Cancel
Save