Summary: | NullPointerException in org.apache.tools.ant.XmlLogger.encode() | ||
---|---|---|---|
Product: | Ant | Reporter: | Robert Enyedi <renyedi> |
Component: | Core | Assignee: | Ant Notifications List <notifications> |
Status: | RESOLVED FIXED | ||
Severity: | normal | Keywords: | PatchAvailable |
Priority: | P3 | ||
Version: | 1.6.2 | ||
Target Milestone: | 1.6.3 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: | This solves the problem for me |
Description
Robert Enyedi
2005-02-08 16:34:48 UTC
Created attachment 14209 [details]
This solves the problem for me
Something logging in XML should know that it is illegal to omit a value from an attribute. The XML Logger adds the following attributes: buildElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); buildElement.element.setAttribute(ERROR_ATTR, event.getException().toString()); An Exception, being a Throwable MUST NOT return null on toString, as this breaches the contract of toString on a Throwable, formatTime should not be returning null either. How can this error be reproduced (Or could you adapt XmlLogger to give some info in case the event.getException().toString() returns null, to know which exception class is broken.) To check this please replace the start of the buildFinished method in the XmlLogger class: public void buildFinished(BuildEvent event) { long totalTime = System.currentTimeMillis() - buildElement.startTime; buildElement.element.setAttribute(TIME_ATTR, DefaultLogger.formatTime(totalTime)); if (event.getException() != null) { String temp = event.getException().toString(); temp = ((temp != null) ? temp : "Throwable with incorrect toString(): " + event.getException().getClass().toString()); buildElement.element.setAttribute(ERROR_ATTR, temp); // print the stacktrace in the build file it is always useful... // better have too much info than not enough. Throwable t = event.getException(); Text errText = doc.createCDATASection(StringUtils.getStackTrace(t)); Element stacktrace = doc.createElement(STACKTRACE_TAG); stacktrace.appendChild(errText); buildElement.element.appendChild(stacktrace); } I think that this is fixed with the fix to bug 31840. (a task name was not set and was used as an attribute value without checking). Can you check with the lastest cvs version of ant. It may be good to use the patch here for safely sake, so I am leaving this bug open. let's assume Peter is correct again. |