ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 30548] New: - NPE in oata.Project when executing emma task from netbeans.
Date Mon, 09 Aug 2004 18:26:58 GMT
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=30548>.
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=30548

NPE in oata.Project when executing emma task from netbeans.

           Summary: NPE in oata.Project when executing emma task from
                    netbeans.
           Product: Ant
           Version: 1.6.1
          Platform: All
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Core
        AssignedTo: dev@ant.apache.org
        ReportedBy: shalmaneser@ePost.de


When I'm using Ant 1.6.1 from within Netbeans 3.6 to execute one of the
emma-tasks, I'm seeing the following stacktrace:

<preceding tasks left out....>
instrument:
java.lang.NullPointerException
       at org.apache.tools.ant.Project.getThreadTask(Project.java:1985)
       at org.apache.tools.ant.Project.demuxFlush(Project.java:1155)
       at
org.apache.tools.ant.DemuxOutputStream.processFlush(DemuxOutputStream.java:186)
       at
org.apache.tools.ant.DemuxOutputStream.flush(DemuxOutputStream.java:211)
       at java.io.PrintStream.flush(PrintStream.java:136)
       at
sun.nio.cs.StreamEncoder$CharsetSE.implFlush(StreamEncoder.java:410)
       at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:152)
       at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
       at java.io.BufferedWriter.flush(BufferedWriter.java:230)
       at java.io.PrintWriter.flush(PrintWriter.java:120)
       at com.vladium.logging.Logger.cleanup(Logger.java:436)
       at com.vladium.logging.Logger.pop(Logger.java:364)
       at com.vladium.emma.Processor.run(Processor.java:60)
       at com.vladium.emma.instr.instrTask.execute(instrTask.java:77)
       at com.vladium.emma.emmaTask.execute(emmaTask.java:57)
       at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
       at org.apache.tools.ant.Task.perform(Task.java:364)
       at org.apache.tools.ant.Target.execute(Target.java:301)
       at org.apache.tools.ant.Target.performTasks(Target.java:328)
       at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
       at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
       at
org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:178)
       at
org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:252)
       at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)

This seems to happen only in Netbeans, not when I'm calling ANT (1.6.0,
or 1.6.2)
from the commandline. (didn't try 1.6.1)

The relevant section in oata.Project is:

  /**
    * Get the current task associated with a thread, if any
    *
    * @param thread the thread for which the task is required.
    * @return the task which is currently registered for the given
thread or
    *         null if no task is registered.
    */
   public Task getThreadTask(Thread thread) {
       Task task = (Task) threadTasks.get(thread); <--- NPE occurs here.
       if (task == null) {
           ThreadGroup group = thread.getThreadGroup();
           while (task == null && group != null) {
               task = (Task) threadGroupTasks.get(group);
               group = group.getParent();
           }
       }
       return task;
   }

Fixing this to read.
   public Task getThreadTask(Thread thread) {
       Object task = threadTasks.get(thread);  // <-- removed cast
       if (task == null) {
           ThreadGroup group = thread.getThreadGroup();
           while (task == null && group != null) {
               task = (Task) threadGroupTasks.get(group);   // ????
               group = group.getParent();
           }
       }
       return (Task) task;  // <-- inserted cast
   }

Solved the problem for me. 
Note, that there is another probable goof in the line marked with // ?????
which could also be prevented by removing the cast.

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


Mime
View raw message