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 209524 - IllegalStateException: Trying to set lookup org.openide.util.Lookup$Empty@44b01d43 but there already is [Ljava.lang.Object;@2d311249 for component: org.netbeans.core.HtmlBrowserComponent[Web Browser,0
Summary: IllegalStateException: Trying to set lookup org.openide.util.Lookup$Empty@44b...
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Embedded Browser (show other bugs)
Version: 7.2
Hardware: All All
: P2 normal (vote)
Assignee: David Konecny
URL:
Keywords:
: 208803 209585 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-13 15:11 UTC by Petr Jiricka
Modified: 2012-09-03 12:54 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 185828


Attachments
stacktrace (1.74 KB, text/plain)
2012-03-13 15:11 UTC, Petr Jiricka
Details
stacktrace (4.05 KB, text/plain)
2012-03-26 16:13 UTC, Petr Jiricka
Details
stacktrace (4.48 KB, text/plain)
2012-05-03 22:47 UTC, John Jullion-ceccarelli
Details
stacktrace (4.59 KB, text/plain)
2012-05-11 06:33 UTC, Exceptions Reporter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2012-03-13 15:11:50 UTC
Build: NetBeans IDE Dev (Build EaselCSS-128-on-20120312)
VM: Java HotSpot(TM) 64-Bit Server VM, 20.4-b02-402, Java(TM) SE Runtime Environment, 1.6.0_29-b11-402-11D50b
OS: Mac OS X

User Comments:
pjiricka: Running an application.




Stacktrace: 
java.lang.IllegalStateException: Trying to set lookup org.openide.util.Lookup$Empty@44b01d43 but there already is [Ljava.lang.Object;@2d311249 for component: org.netbeans.core.HtmlBrowserComponent[Web Browser,0,0,1071x735,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=256,maximumSize=,minimumSize=,preferredSize=]
   at org.openide.windows.TopComponent.setLookup(TopComponent.java:1381)
   at org.openide.windows.TopComponent.associateLookup(TopComponent.java:1366)
   at org.netbeans.core.HtmlBrowserComponent.setURLAndOpen(HtmlBrowserComponent.java:380)
   at org.netbeans.modules.web.browser.api.WebBrowserPane$2.run(WebBrowserPane.java:186)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
Comment 1 Petr Jiricka 2012-03-13 15:11:53 UTC
Created attachment 116675 [details]
stacktrace
Comment 2 Denis Anisimov 2012-03-14 05:52:39 UTC
Lookup is changed via associateLookup() call which is added by David.
But it seems the issue is generic : it is race condition.
I don't see any other reason to have lookup initialized when browserComponent 
is null.
It could be a problem of deserialization (if it is called outside of AWT thread).
browserComponent is initialized on the deserialization along with lookup.
But setURLAndOpen() is called inside AWT thread where browserComponent is null.
It means that browserComponent is initialized twice : on deserialization and inside setURLAndOpen() and this is bug. 
So the problem is not lookup itself.
Comment 3 Denis Anisimov 2012-03-14 17:06:09 UTC
*** Bug 209585 has been marked as a duplicate of this bug. ***
Comment 4 Petr Jiricka 2012-03-14 21:10:23 UTC
I can confirm that this happened after IDE startup when embedded browser was open. So in which component this needs to be fixed?
Comment 5 Denis Anisimov 2012-03-15 05:51:14 UTC
That's the bug inside org.netbeans.core.HtmlBrowserComponent class,
o.n.core module.
I'm not sure what component exactly should be used.
Comment 6 Petr Jiricka 2012-03-15 09:18:16 UTC
Then I guess this is Standa's.
Comment 7 Petr Jiricka 2012-03-26 16:13:36 UTC
Created attachment 117270 [details]
stacktrace

Running a client-side project after closing the embedded browser window.
Comment 8 Stanislav Aubrecht 2012-03-28 10:05:41 UTC
*** Bug 208803 has been marked as a duplicate of this bug. ***
Comment 9 John Jullion-ceccarelli 2012-05-03 22:47:40 UTC
Created attachment 119051 [details]
stacktrace

opening IDE with internal javafx browser open
Comment 10 Petr Jiricka 2012-05-04 07:43:14 UTC
-> P2.
Comment 11 Exceptions Reporter 2012-05-11 06:33:00 UTC
Created attachment 119330 [details]
stacktrace
Comment 12 David Konecny 2012-05-15 06:58:02 UTC
This is very annoying as it happens too often. To reproduce the issue follow these steps:
* open a file in embedded browser
* close the embedded browser
* open a file in embedded browser

Second opening of embedded browser throws attached exception. It look like first closing of embedded browser does not actually close the TopComponent - it closed embedded browser component but owning TopComponent gets what? gets hidden? I'm workarounding this by enforcing new TopComponent creation. Can be right fix, can be wrong. Standa, could you review please? Thanks.

e3169ac1eb16
Comment 13 Jan Stola 2012-05-23 13:33:34 UTC
> I'm workarounding this by enforcing new TopComponent creation. Can be
> right fix, can be wrong.

David, I am reopening this issue because this doesn't seem to be the right fix.

First of all, your workaround does nothing when the HtmlBrowserComponent is not opened through WebBrowserPane. The following steps lead to the same exception even with your change applied:

* Open Tools > Online Docs and Support
* close Online Docs and Support
* Open Tools > Online Docs and Support again

Moreover, the empty body of your componentClosed() fails to trigger actions associated with the closure of HtmlBrowserComponent like end of debugging and page inspection.

> Second opening of embedded browser throws attached exception. It look like
> first closing of embedded browser does not actually close the TopComponent
> - it closed embedded browser component but owning TopComponent gets what?
> gets hidden?

There seems to be a confusion between closure and destruction/disposal. When HtmlBrowserComponent is closed then the corresponding HtmlBrowser is disposed (i.e., not reused when HtmlBrowserComponent is opened again). In other words, a new HtmlBrowser is created whenever HtmlBrowserComponent is opened.

The changes that you introduced with the lookup changes are not compatible with this life-cycle. You call associateLookup() whenever HtmlBrowser is created, i.e., whenever HtmlBrowserComponent is opened. This is the root of the exception. associateLookup() can be called just once. Hence, it throws the attached exception when HtmlBrowserComponent is opened for the second time.

I believe that the right fix is the rewrite of the handling of HtmlBrowserComponent's lookup. You should make sure that associateLookup() is called just once. For example, you can call associateLookup(someProxyLookup) is constructor and update the content of 'someProxyLookup' in componentActivated() and componentClosed() methods (that instantiate/dispose HtmlBrowser).
Comment 14 Stanislav Aubrecht 2012-05-23 13:37:33 UTC
I've made some changes in 72e70a1 that take care of the associateLookup() problem - it is always called just once now.

Not sure what should happen in HtmlBrowserComponent.componentClosed() though.
Comment 15 Jan Stola 2012-05-23 16:49:15 UTC
> I've made some changes in 72e70a1 that take care of the associateLookup()
> problem - it is always called just once now.

I see. Hence, some parts of my previous comment are no longer valid after this change, I guess.

> Not sure what should happen in HtmlBrowserComponent.componentClosed() though.

I added super.componentClosed() into WebBrowserPane$2 (that extends HTMLBrowserComponent) to trigger shutdown of webkit debugging and page inspection (see http://hg.netbeans.org/web-main/rev/35aaccea7dc4 ) and everything I checked seems to work fine now.
Comment 16 David Konecny 2012-05-25 04:35:26 UTC
Thanks for fixing it properly guys. Should the issue be closed now?
Comment 17 David Konecny 2012-08-20 03:41:38 UTC
Issue was not closed when it was fixed.
Comment 18 Quality Engineering 2012-09-03 12:54:43 UTC
Integrated into 'main-golden', will be available in build *201209031048* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e3169ac1eb16
User: David Konecny <dkonecny@netbeans.org>
Log: #209524 - IllegalStateException: Trying to set lookup org.openide.util.Lookup