This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 85621 - Got AssertionError in ResultDisplayHandler
Summary: Got AssertionError in ResultDisplayHandler
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Marian Petras
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2006-09-23 02:17 UTC by Jun Qian
Modified: 2006-10-23 16:40 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
NetBeans version (18.87 KB, application/octet-stream)
2006-09-23 02:30 UTC, Jun Qian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jun Qian 2006-09-23 02:17:55 UTC
I got the following assertion while trying to run some junit test. However I
can't easily reproduce this problem. It seemed to have something to do with my
consecutive junit test invokations.

java.lang.AssertionError
	at
org.netbeans.modules.junit.output.ResultDisplayHandler.displayReport(ResultDisplayHandler.java:286)
	at org.netbeans.modules.junit.output.Manager.displayReport(Manager.java:312)
	at
org.netbeans.modules.junit.output.JUnitOutputReader.suiteFinished(JUnitOutputReader.java:542)
	at
org.netbeans.modules.junit.output.JUnitOutputReader.closePreviousReport(JUnitOutputReader.java:730)
	at
org.netbeans.modules.junit.output.JUnitOutputReader.finishReport(JUnitOutputReader.java:553)
	at
org.netbeans.modules.junit.output.JUnitOutputReader.buildFinished(JUnitOutputReader.java:520)
	at
org.netbeans.modules.junit.output.JUnitAntLogger.buildFinished(JUnitAntLogger.java:173)
	at
org.apache.tools.ant.module.bridge.impl.NbBuildLogger.buildFinished(NbBuildLogger.java:368)
	at org.apache.tools.ant.Project.fireBuildFinished(Project.java:1848)
	at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:247)
	at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:293)
[catch] at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131)
Comment 1 Jun Qian 2006-09-23 02:30:13 UTC
Created attachment 34408 [details]
NetBeans version
Comment 2 Marian Petras 2006-09-24 22:08:23 UTC
Accepted.
Comment 3 Marian Petras 2006-09-24 22:09:29 UTC
It seems to be revision 1.3.4.1.2.1 of ResultDisplayHandler.java.
Comment 4 Marian Petras 2006-09-24 22:47:32 UTC
The assertion error really marks an error in the source code, specificaly a
missing assignment statement in method setTreePanel(...):

   ...
   if (runningSuite != null) {
       treePanel.displaySuiteRunning(...)
+      runningSuite = null;
   }
   ...

The consequence of the missing statement is that after the setTreePanel(...) 
method is called, variable 'runningSuite' may be non-null while it *should* be
null (according to the meaning of the variable). The correct value (according to
the declaration) is later checked by the assert statement at line 286 - and it
fails. But although the strict logic says "variable 'runningSuite' should be
reset to null after its value was passed to the 'treePanel'", in fact, variable
'runningSuite' becomes insignificant once method setTreePanel(...) has been
called. In other words, the failing assert statement checks a correct value
(according to the declaration) of a a currently meaningless variable/field.

Briefly - the bug can be fixed by any of the following ways:
 - addition of the missing assertion statement
 - removal of the failing assertion statement at line 286
 - disabling of assertion checks in class ResultDisplayHandler

In final version of NetBeans 5.5, all assertion statements will be disabled - so
this bug will not manifest itself in the final version.

In development versions of NetBeans 5.5 (and NB 6.0), it is possible to
workaround the bug by disabling assertion checks for class ResultDisplayHandler.
To do so, modify file <netbeans-install-dir>/etc/netbeans.conf - add the
following switch *after* switch "-J-ea" in the line beginning with
"netbeans_default_options=":

    -J-da:org.netbeans.modules.junit.output.ResultDisplayHandler

I will make the proper fix to NetBeans 6.0 but I will not make it in NetBeans
5.5 (too late for non-critical fixes).
Comment 5 Marian Petras 2006-09-24 22:49:49 UTC
Correction:
There should be "addition of the missing *assignment* statement" in the text above.
Comment 6 Marian Petras 2006-09-25 15:37:17 UTC
Fixed in the trunk.

Modified file:
    junit/src/org/netbeans/modules/junit/output/ResultDisplayHandler.java   (1.8)

Diff:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/ResultDisplayHandler.java?r1=1.7&r2=1.8&diff_format=u