Browse Source

fix NPE when logging an exception without message. PR 47623.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@800678 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
f00dea8ea7
3 changed files with 15 additions and 0 deletions
  1. +4
    -0
      WHATSNEW
  2. +3
    -0
      src/main/org/apache/tools/ant/Project.java
  3. +8
    -0
      src/tests/junit/org/apache/tools/ant/ProjectTest.java

+ 4
- 0
WHATSNEW View File

@@ -420,6 +420,10 @@ Fixed bugs:
failed to load.
Bugzilla Report 44103.

* Logging exceptions without a message would cause a
NullPointerException.
Bugzilla Report 47623.

Other changes:
--------------
* The get task now also follows redirects from http to https


+ 3
- 0
src/main/org/apache/tools/ant/Project.java View File

@@ -2171,6 +2171,9 @@ public class Project implements ResourceFactory {
private void fireMessageLoggedEvent(BuildEvent event, String message,
int priority) {

if (message == null) {
message = String.valueOf(message);
}
if (message.endsWith(StringUtils.LINE_SEP)) {
int endIndex = message.length() - StringUtils.LINE_SEP.length();
event.setMessage(message.substring(0, endIndex), priority);


+ 8
- 0
src/tests/junit/org/apache/tools/ant/ProjectTest.java View File

@@ -276,6 +276,14 @@ public class ProjectTest extends TestCase {
assertTrue("Expected logging thread to finish successfully", done[0]);
}

/**
* @see https://issues.apache.org/bugzilla/show_bug.cgi?id=47623
*/
public void testNullThrowableMessageLog() {
p.log(new Task() {}, null, new Throwable(), Project.MSG_ERR);
// be content if no exception has been thrown
}

private class DummyTaskPrivate extends Task {
public DummyTaskPrivate() {}
public void execute() {}


Loading…
Cancel
Save