ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r800678 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/Project.java src/tests/junit/org/apache/tools/ant/ProjectTest.java
Date Tue, 04 Aug 2009 05:38:44 GMT
Author: bodewig
Date: Tue Aug  4 05:38:43 2009
New Revision: 800678

URL: http://svn.apache.org/viewvc?rev=800678&view=rev
Log:
fix NPE when logging an exception without message.  PR 47623.

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/Project.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=800678&r1=800677&r2=800678&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Aug  4 05:38:43 2009
@@ -420,6 +420,10 @@
    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

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?rev=800678&r1=800677&r2=800678&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Tue Aug  4 05:38:43 2009
@@ -2171,6 +2171,9 @@
     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);

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java?rev=800678&r1=800677&r2=800678&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java Tue Aug  4 05:38:43
2009
@@ -276,6 +276,14 @@
         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() {}



Mime
View raw message