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 232167 - ErrorManagerDelegatesToLoggingTest.testAnnotateExceptionWithCNFECause fails with NPE
Summary: ErrorManagerDelegatesToLoggingTest.testAnnotateExceptionWithCNFECause fails w...
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.3.1
Hardware: All All
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: JDK_SPECIFIC
: 234650 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-07-02 18:33 UTC by AlexanderIoffe
Modified: 2013-12-19 06:52 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description AlexanderIoffe 2013-07-02 18:33:01 UTC
Two tests fail with the same Error:

testAnnotateCNFE
testAnnotateExceptionWithCNFECause

java.lang.NullPointerException
at org.openide.ErrorManager$AnnException.getMessage(ErrorManager.java:849)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at java.util.Objects.toString(Objects.java:157)
at java.lang.Throwable.initCause(Throwable.java:456)
at org.openide.ErrorManager$AnnException.findOrCreate0(ErrorManager.java:882)
at org.openide.ErrorManager$AnnException.findOrCreate0(ErrorManager.java:886)
at org.openide.ErrorManager$AnnException.findOrCreate(ErrorManager.java:862)
at org.openide.ErrorManager$DelegatingErrorManager.annotate(ErrorManager.java:653)
at org.openide.ErrorManagerDelegatesToLoggingTest.testAnnotateExceptionWithCNFECause(ErrorManagerDelegatesToLoggingTest.java:178)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at junit.framework.TestCase.runTest(TestCase.java:168)
at org.netbeans.junit.NbTestCase.access$200(NbTestCase.java:97)
at org.netbeans.junit.NbTestCase$2.doSomething(NbTestCase.java:431)
at org.netbeans.junit.NbTestCase$1Guard.run(NbTestCase.java:357)
at java.lang.Thread.run(Thread.java:724)


Analysis shows that 
at org.openide.ErrorManager$AnnException.findOrCreate0(ErrorManager.java:882)
creates new AnnException with empty constructor
and later
at org.openide.ErrorManager$AnnException.getMessage(ErrorManager.java:849)
tries to itearate over it's field


Looks like it's a product bug, but I'm not sure about the correct component
Comment 1 AlexanderIoffe 2013-07-03 12:39:10 UTC
More tests fail with the same reason:
ExceptionsTest testAttachMessageForClassNotFound
ExceptionsTest testAttachLocalizedMessageForClassNFE
ExceptionsTest testAttachLocalizedMessageForClassNFEIfNoMsg	
ExceptionsTest testAnnotateExceptionWithCNFECause
ExceptionsTest 	testAnnotateCNFE
Comment 2 Jiri Skrivanek 2013-07-04 08:52:36 UTC
I tried to run the test both in trun and 7.3.1 code base and it works for me (Windows7, JDK7u25):

 ant -f openide.util test-unit -Dtest.includes=**/ErrorManagerDelegatesToLoggingTest.class

Also the test passes on all platforms for trunk. E.g. on Linux:

http://hudson4qe.cz.oracle.com/view/Trunk-QE/job/StableBTD-7.4/15/jdk=JDK%207,label=Ubuntu-slave3/testReport/org.openide/ErrorManagerDelegatesToLoggingTest/

Please, provide your steps and environment to reproduce failure.
Comment 3 Jiri Skrivanek 2013-07-15 09:25:54 UTC
Mentioned test fails with jdk1.7.0_40. It is because ErrorManager at line 849 does not check the records field for null ("for (LogRecord r : records) {"). Here is comment by Alexander about changes in Throwable.initCause:

Here at java.lang.Throwable.initCause(Throwable.java:456) we have a Objects.toString() call. However, this change is intentional. This is a part of fix for JDK-8012044. The idea is just to provide a bit more information to user throwing IllegalStateException

Current code is:

    454     public synchronized Throwable initCause(Throwable cause) {
    455         if (this.cause != this)
    456             throw new IllegalStateException("Can't overwrite cause with " +
    457                                             Objects.toString(cause, "a null"), this);
    458         if (cause == this)
    459             throw new IllegalArgumentException("Self-causation not permitted", this);
    460         this.cause = cause;
    461         return this;
    462     }

Previous code was:
    454     public synchronized Throwable initCause(Throwable cause) {
    455         if (this.cause != this)
    456             throw new IllegalStateException("Can't overwrite cause");
    457         if (cause == this)
    458             throw new IllegalArgumentException("Self-causation not permitted");
    459         this.cause = cause;
    460         return this;
    461     }

So I see now two problems in NB:
 1. Trying to call initCause when it's not allowed and so you'll get IllegalStateException
 2. Having AnnException.toString() not defended from NPE, which is not good anyway.
Comment 4 Jiri Skrivanek 2013-08-20 14:03:21 UTC
Fails regularly within stable test distribution because we switched to JDK 1.7.0_40-b40.

http://hudson4qe.cz.oracle.com/view/Trunk-QE/job/StableBTD-7.4/59/jdk=JDK%207,label=XP-slave2/testReport/org.openide/ErrorManagerDelegatesToLoggingTest/testAnnotateCNFE
Comment 5 Jaroslav Tulach 2013-08-22 11:53:12 UTC
ergonomics#ce5e042bebba
Comment 6 Jiri Skrivanek 2013-08-30 05:56:48 UTC
erogonomics builder still failing. Not yet fixed in main-silver.
Comment 7 Jaroslav Tulach 2013-08-30 10:19:57 UTC
The build fails due to #234996. That is not under my control. From my point of view the issue is fixed, so don't reopen it for me, I can't do anything more.
Comment 8 Quality Engineering 2013-09-01 01:27:25 UTC
Integrated into 'main-silver', will be available in build *201309010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ce5e042bebba
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #232167: Prevent NPE on 1.7.0_40
Comment 9 Martin Fousek 2013-12-19 06:52:23 UTC
*** Bug 234650 has been marked as a duplicate of this bug. ***