timboudreau opened a new issue, #4510:
URL: https://github.com/apache/netbeans/issues/4510
### Apache NetBeans version
Apache NetBeans 15 release candidate
### What happened
IDE locks up after opening the Inspect and Transform dialog against a Java
source, and then clicking Manage.
I've seen this a couple of times, so I pulled a thread-dump.
The root cause is that `InspectAndRefactorPanel` takes a lock on itself in
`manageConfigurationsActionPerformed`, but that lock is shared with the
inherited synchronized method `addContainerListener`.
Via accessibility support, the `AppKit` thread (the native Mac OS event
thread) is blocked on adding a container listener to the panel, in order to
show the dialog - but it cannot because the AWT thread is holding the lock.
The AWT thread will hold the lock until the native dialog is opened, which it
never will be, because the AppKit thread is blocked on the lock.
*Simple Solution*: `manageConfigurationsActionPerformed` - if it needs to
be synchronized at all - must use a private lock not shared by any inherited
methods.
(and in general, never write `synchronized` methods in a Swing component or
use `synchronized(this)` in one - you have no idea what else you're sharing the
lock with, and what you're sharing it with will vary by look and feel and OS)
```
"AppKit Thread" #21 daemon prio=5 os_prio=31 cpu=5255367.20ms
elapsed=216720.56s tid=0x000000011e89d400 nid=0x103 waiting for monitor entry
[0x000000016b738000]
java.lang.Thread.State: BLOCKED (on object monitor)
at
java.awt.Container.addContainerListener([email protected]/Container.java:2149)
- waiting to lock <0x00000007b0da2638> (a
org.netbeans.modules.java.hints.spiimpl.refactoring.InspectAndRefactorPanel)
at
java.awt.Container$AccessibleAWTContainer.addPropertyChangeListener([email protected]/Container.java:3920)
at
javax.swing.JComponent$AccessibleJComponent.addPropertyChangeListener([email protected]/JComponent.java:3820)
at
sun.lwawt.macosx.CAccessible.addNotificationListeners([email protected]/CAccessible.java:108)
at
sun.lwawt.macosx.CAccessible.<init>([email protected]/CAccessible.java:90)
at
sun.lwawt.macosx.CAccessible.getCAccessible([email protected]/CAccessible.java:61)
"AWT-EventQueue-0" #25 prio=6 os_prio=31 cpu=7806878.27ms elapsed=216720.38s
tid=0x000000011fb41000 nid=0x11f03 runnable [0x000000016f5d7000]
java.lang.Thread.State: RUNNABLE
at
java.util.PriorityQueue.siftUpComparable([email protected]/PriorityQueue.java:651)
at
java.util.PriorityQueue.siftUp([email protected]/PriorityQueue.java:639)
at
java.util.PriorityQueue.offer([email protected]/PriorityQueue.java:330)
at
java.util.concurrent.DelayQueue.offer([email protected]/DelayQueue.java:147)
at
java.util.concurrent.DelayQueue.add([email protected]/DelayQueue.java:133)
at
javax.swing.TimerQueue.addTimer([email protected]/TimerQueue.java:139)
at
javax.swing.TimerQueue.addTimer([email protected]/TimerQueue.java:123)
at javax.swing.Timer.start([email protected]/Timer.java:553)
at
com.apple.laf.AquaProgressBarUI$Animator.actionPerformed([email protected]/AquaProgressBarUI.java:498)
at
javax.swing.Timer.fireActionPerformed([email protected]/Timer.java:311)
at javax.swing.Timer$DoPostEvent.run([email protected]/Timer.java:243)
at
java.awt.event.InvocationEvent.dispatch([email protected]/InvocationEvent.java:318)
at
java.awt.EventQueue.dispatchEventImpl([email protected]/EventQueue.java:771)
at java.awt.EventQueue$4.run([email protected]/EventQueue.java:722)
at java.awt.EventQueue$4.run([email protected]/EventQueue.java:716)
at
java.security.AccessController.executePrivileged([email protected]/AccessController.java:776)
at
java.security.AccessController.doPrivileged([email protected]/AccessController.java:399)
at
java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege([email protected]/ProtectionDomain.java:86)
at
java.awt.EventQueue.dispatchEvent([email protected]/EventQueue.java:741)
at
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
at
java.awt.EventDispatchThread.pumpOneEventForFilters([email protected]/EventDispatchThread.java:203)
at
java.awt.EventDispatchThread.pumpEventsForFilter([email protected]/EventDispatchThread.java:124)
at
java.awt.EventDispatchThread.pumpEventsForFilter([email protected]/EventDispatchThread.java:117)
at
java.awt.WaitDispatchSupport$2.run([email protected]/WaitDispatchSupport.java:191)
at
java.awt.WaitDispatchSupport$4.run([email protected]/WaitDispatchSupport.java:236)
at
java.awt.WaitDispatchSupport$4.run([email protected]/WaitDispatchSupport.java:234)
at
java.security.AccessController.executePrivileged([email protected]/AccessController.java:776)
at
java.security.AccessController.doPrivileged([email protected]/AccessController.java:318)
at
java.awt.WaitDispatchSupport.enter([email protected]/WaitDispatchSupport.java:234)
at java.awt.Dialog.show([email protected]/Dialog.java:1080)
at
org.netbeans.core.windows.services.NbPresenter.superShow(NbPresenter.java:1074)
at
org.netbeans.core.windows.services.NbPresenter.doShow(NbPresenter.java:1124)
at
org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:1096)
at
org.netbeans.core.windows.services.NbPresenter.run(NbPresenter.java:106)
at
org.netbeans.modules.openide.util.NbMutexEventProvider$Event.doEventAccess(NbMutexEventProvider.java:123)
at
org.netbeans.modules.openide.util.NbMutexEventProvider$Event.readAccess(NbMutexEventProvider.java:77)
at
org.netbeans.modules.openide.util.LazyMutexImplementation.readAccess(LazyMutexImplementation.java:71)
at org.openide.util.Mutex.readAccess(Mutex.java:199)
at
org.netbeans.core.windows.services.NbPresenter.show(NbPresenter.java:1081)
at java.awt.Component.show([email protected]/Component.java:1728)
at
java.awt.Component.setVisible([email protected]/Component.java:1675)
at java.awt.Window.setVisible([email protected]/Window.java:1036)
at java.awt.Dialog.setVisible([email protected]/Dialog.java:1016)
at
org.netbeans.modules.java.hints.spiimpl.refactoring.InspectAndRefactorPanel.manageRefactorings(InspectAndRefactorPanel.java:639)
- locked <0x00000007b0da2638> (a
org.netbeans.modules.java.hints.spiimpl.refactoring.InspectAndRefactorPanel)
at
org.netbeans.modules.java.hints.spiimpl.refactoring.InspectAndRefactorPanel.manageConfigurationsActionPerformed(InspectAndRefactorPanel.java:386)
```
### How to reproduce
Just attempt to open the dialog on a similarly Mac OS.
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Mac OS X 21.4.0, Apple Silicon 10 Core MacBook Pro
### JDK
Amazon Corretto 17
### Apache NetBeans packaging
Own source build
### Anything else
I have opened the dialog successfully, so not every time - it appears to
depend on how the AppKit thread's tasks get scheduled relative to the AWT
thread's tasks.
### Are you willing to submit a pull request?
Yes
### Code of Conduct
Yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists