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 178294 - Possible ConcurrentModificationException in KeymapModel.getActionCategories()
Summary: Possible ConcurrentModificationException in KeymapModel.getActionCategories()
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Key bindings (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 normal (vote)
Assignee: David Strupl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-08 06:18 UTC by fvogler
Modified: 2009-12-16 12:15 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Make KeymapModel.getActionCategories() thread safe (2.25 KB, patch)
2009-12-08 06:18 UTC, fvogler
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description fvogler 2009-12-08 06:18:17 UTC
Created attachment 92270 [details]
Make KeymapModel.getActionCategories() thread safe

Lazy initialization in org.netbeans.modules.options.keymap.KeymapModel.getActionCategories() is not thread safe.

java.util.ConcurrentModificationException
        at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
        at java.util.AbstractList$Itr.next(AbstractList.java:343)
        at org.netbeans.modules.options.keymap.KeymapModel.getActionCategories(KeymapModel.java:96)
        at org.netbeans.modules.options.keymap.KeymapModel.<init>(KeymapModel.java:445)
        at org.netbeans.modules.options.keymap.KeymapViewModel.<init>(KeymapViewModel.java:84)
        at org.netbeans.modules.options.keymap.KeymapPanel.getModel(KeymapPanel.java:227)
        at org.netbeans.modules.options.keymap.KeymapPanel.<init>(KeymapPanel.java:94)
        at org.netbeans.modules.options.keymap.KeymapPanelController.getKeymapPanel(KeymapPanelController.java:106)
        at org.netbeans.modules.options.keymap.KeymapPanelController.getLookup(KeymapPanelController.java:86)
        at org.netbeans.modules.options.CategoryModel$Category.getLookup(CategoryModel.java:431)
        at org.netbeans.modules.options.CategoryModel$Category.access$000(CategoryModel.java:313)
        at org.netbeans.modules.options.CategoryModel$1.run(CategoryModel.java:93)
Caused: org.openide.util.RequestProcessor$SlowItem: task failed due to
        at org.openide.util.RequestProcessor$Task.schedule(RequestProcessor.java:694)
        at org.netbeans.modules.options.CategoryModel$2.run(CategoryModel.java:115)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:641)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1123)
Comment 1 David Strupl 2009-12-15 03:53:06 UTC
I will have a look at this.
Comment 2 David Strupl 2009-12-15 04:12:38 UTC
I will not apply the patch as is since calling
Lookup.getDefault().lookupAll(KeymapManager.class) while holding any kind of lock is rather dangerous (because it can block). I will try to solve the exception differently. 

BTW calling org.netbeans.modules.options.keymap.KeymapPanel.<init>(KeymapPanel.java:94) not from AWT EDT is rather wrong since it is a swing call ...
Comment 3 David Strupl 2009-12-15 07:17:58 UTC
Changeset: 2a96468ccd85
Author:    David Strupl <dstrupl@netbeans.org>
Date:      2009-12-15 15:18
Message:   KeymapModel.getKeymapManagerInstances() synchronized
Issue #178294 - Possible ConcurrentModificationException in KeymapModel.getActionCategories()
Comment 4 David Strupl 2009-12-15 07:21:42 UTC
The fix is almost the same as the original patch - thanks. I have just made the synchronized section smaller ...
Comment 5 Quality Engineering 2009-12-16 12:15:20 UTC
Integrated into 'main-golden', will be available in build *200912161400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/2a96468ccd85
User: David Strupl <dstrupl@netbeans.org>
Log: KeymapModel.getKeymapManagerInstances() synchronized
Issue #178294 - Possible ConcurrentModificationException in KeymapModel.getActionCategories()