You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2005/02/08 16:34:48 UTC

DO NOT REPLY [Bug 33446] New: - NullPointerException in org.apache.tools.ant.XmlLogger.encode()

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33446>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33446

           Summary: NullPointerException in
                    org.apache.tools.ant.XmlLogger.encode()
           Product: Ant
           Version: 1.6.2
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Keywords: PatchAvailable
          Severity: normal
          Priority: P3
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: renyedi@yahoo.com


I found this problem while automating my build process. I am using CruiseControl
2.2 which outputs logs in XML format and uses Ant's XML logger.

This is my stack trace:

java.lang.NullPointerException
        at
org.apache.tools.ant.util.DOMElementWriter.encode(DOMElementWriter.java:174)
        at
org.apache.tools.ant.util.DOMElementWriter.write(DOMElementWriter.java:95)
        at
org.apache.tools.ant.util.DOMElementWriter.write(DOMElementWriter.java:113)
        at org.apache.tools.ant.XmlLogger.buildFinished(XmlLogger.java:189)
        at org.apache.tools.ant.Project.fireBuildFinished(Project.java:1796)
        at org.apache.tools.ant.Main.runBuild(Main.java:693)
        at org.apache.tools.ant.Main.startAnt(Main.java:188)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

The line the exception occurs is:

int len = value.length();

"value" being the method's argument.

The fix seems obvious by checking value for null and in this case initializing
len with 0:

int len = (value==null ? 0 : value.length());

This worked for me.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org