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 40937 - change of SaveCookie from non-AWT thread causes exceptions
Summary: change of SaveCookie from non-AWT thread causes exceptions
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Actions (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2004-03-11 18:46 UTC by Marian Petras
Modified: 2008-12-22 22:58 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
suggested patch (1.50 KB, patch)
2004-04-30 16:14 UTC, Marian Petras
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Petras 2004-03-11 18:46:02 UTC
If a cookie change is fired
(Node.fireCookieChange()) from a thread other than
AWT-event-queue, an IllegalStateException is thrown.

The problem is that the change causes some action
(probably Save action) to be enabled/disabled
which must be done in the AWT-event-queue. And
because it is called from another thread, the
exception is thrown.
Comment 1 Marian Petras 2004-03-11 18:50:25 UTC
The exception is available at
http://www.netbeans.org/issues/showattachment.cgi?attach_id=13929&file=Exception.txt
(the second attachment of bug #37524).
Comment 2 Jiri Rechtacek 2004-04-23 10:50:31 UTC
Assigned to new owner.
Comment 3 Jiri Rechtacek 2004-04-30 14:42:11 UTC
Yes, the IllegalStateExceptio is thrown if the action's is changes
outside of EventQueue. You have to replan firing this change to EQ in
properties module. See fix of issue 41500.
Comment 4 Marian Petras 2004-04-30 16:13:15 UTC
I do not agree the problem should be fixed in module Properties. The
reason is that the action's state change is initiated in the OpenIDE's
part of code, outside of the Preperties module's scope.

I suggest that the check for the current thread (and possible
redirection to the AWT-event-queue thread) should be performed at the
moment it is apparent the cookie change would change the action's
state change. I think the right place is in method

     org.openide.util.actions.CookieAction.CookiesChangeListener
                                                   .propertyChange(...)

See the attached diff.
Comment 5 Marian Petras 2004-04-30 16:14:42 UTC
Created attachment 14647 [details]
suggested patch
Comment 6 Jaroslav Tulach 2004-08-16 18:06:23 UTC
I can apply Marian's patch and I'll do it tomorrow, if nobody closes
this bug as wontfix by then.
Comment 7 Jesse Glick 2004-08-16 18:14:03 UTC
Should be OK for D. In the future, the property change would always
arrive from EQ anyway, so this call to Mutex.EVENT could just be
replaced with an assertion.
Comment 8 Jaroslav Tulach 2004-08-17 14:51:15 UTC
cvs -q ci -m "#40937: Cookies can change in any thread"

Checking in src/org/openide/util/actions/CookieAction.java;
/cvs/openide/src/org/openide/util/actions/CookieAction.java,v  <-- 
CookieAction.java
new revision: 1.26; previous revision: 1.25
done
Processing log script arguments...
More commits to come...
Checking in test/unit/src/org/openide/util/actions/CookieAction2Test.java;
/cvs/openide/test/unit/src/org/openide/util/actions/CookieAction2Test.java,v
 <--  CookieAction2Test.java
new revision: 1.2; previous revision: 1.1
Comment 9 Marian Petras 2004-10-29 15:00:19 UTC
Verified. The exceptions are not thrown any more.