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 56826 - output2: Get NPEs in clearListeners when calling reset()
Summary: output2: Get NPEs in clearListeners when calling reset()
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Output Window (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-23 07:57 UTC by Torbjorn Norbye
Modified: 2008-12-22 11:13 UTC (History)
0 users

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 Torbjorn Norbye 2005-03-23 07:57:09 UTC
In certain error conditions my code opens an output window and writes to it. It
may also call reset() first.

This reset() often leads to a nNPE:

java.lang.NullPointerException
        at org.netbeans.core.output2.OutWriter.clearListeners(OutWriter.java:300)
        at org.netbeans.core.output2.OutWriter.dispose(OutWriter.java:269)
        at org.netbeans.core.output2.NbWriter.reset(NbWriter.java:70)
        ... (my module code calling reset)


It took a brief look and it looks like the getListenerForLine method may return
null so there should be some extra checks.

Or is there some restriction on reset() I'm not aware of?

The client code looks something like this:

        InputOutput io =
IOProvider.getDefault().getIO(NbBundle.getMessage("foo"), false);
        OutputWriter out = io.getOut();
        try {
            if (clearErrors) {
                out.reset();
            }
            out.println(message, listener);
        }
        catch (IOException ioe) {
             ...


This is from sources that are not completely current, but they are more recent
than beta.
Comment 1 Milos Kleint 2005-03-23 14:37:36 UTC
are you adding a null listener sometimes when printing to the output?

the clearing before writing pattern is quite common AFAIK, so there must be
something else..

maybe you call reset on one instance from various threads in a short timeframe
(kind of race condition)?
Comment 2 Milos Kleint 2005-03-29 13:44:52 UTC
i've "fixed" the problem by checking for the null value and also added some
ErrorManager messages hat should help us figure out the sources of the problem.
please reopen if it happens to you again.
Comment 3 Jesse Glick 2007-04-09 23:25:37 UTC
I got this in a dev build:

WARNING [null]: Issue #56826 - Adding a null OutputListener for line:50
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:51
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:52
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:53
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:54
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:55
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:56
WARNING [null]: Issue #56826 - Adding a null OutputListener for line:57
[etc.]

I fixed the code to print a stack trace so we will know the culprit next time.