andresluuk opened a new issue, #9786:
URL: https://github.com/apache/netbeans/issues/9786
### Apache NetBeans version
Apache NetBeans 31
### What happened
### Apache NetBeans version
Apache NetBeans 31 (build `31-f8ac37e0f2434a7f000fbe3360f1a92aa3ea67bc`)
### What happened
Sometimes, right after startup, one main-window toolbar is missing for the
whole session. The other toolbars are there and the rest of the IDE works
normally. **View > Toolbars** does not bring it back for that session; a
restart does.
At the same moment, `messages.log` records:
```
INFO [org.openide.loaders.FolderInstance.Toolbars]: Cannot create
org.openide.loaders.FolderInstance$HoldInstance@74415702[Toolbars/Build]
java.io.IOException: Cyclic reference. Somebody is trying to get value from
FolderInstance (org.openide.awt.Toolbar$Folder) from the same thread that is
processing the instance
at
org.openide.loaders.FolderInstance.instanceCreate(FolderInstance.java:274)
at
org.openide.loaders.FolderInstance.instanceForCookie(FolderInstance.java:555)
at
org.openide.loaders.FolderInstance$HoldInstance.instanceCreate(FolderInstance.java:1132)
[catch] at
org.openide.loaders.FolderInstance$1R.instances(FolderInstance.java:675)
at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:696)
at
org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1370)
at
org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
at
org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1981)
```
The missing toolbar is always the one named in the `Cannot create
...[Toolbars/<name>]` line, and which toolbar it is varies between runs. We
have seen two cases:
| Date | Missing toolbar | Log lines just before the exception |
|---|---|---|
| 2026-10-24 | `Toolbars/File` (New/Open/Save buttons gone) |
`USG_PROJECT_OPEN_MAVEN`, `USG_PROJECT_OPEN` |
| 2026-11-05 | `Toolbars/Build` (Run/Debug/Build buttons gone) |
`USG_PROJECT_OPEN_MAVEN`; next line is `USG_LOOK_AND_FEEL` |
In both cases the exception appears about 1 second after the main window has
shown and the last-opened Maven project is restored.
This is the same message as NETBEANS-6458. That issue was fixed in NetBeans
14 by apache/netbeans#3635, which made the `FolderInstance` fields `volatile`.
The problem still reproduces in 31.
### How to reproduce
We can't reproduce it on demand. We have seen int twice on our automated UI
test machines:
1. Start NetBeans 31 with a user directory whose last session had a Maven
Java project open, so the project is restored on startup.
2. Look at the main toolbar row once the window has shown.
3. Occasionally, one toolbar is missing and the stack trace above is in
`messages.log`.
### Possible cause (from reading the 31 sources)
We can't prove this, but the code suggests the following:
- `ToolbarPool.Folder` pre-creates the toolbars on the `FolderInstance`
request processor thread. In `FolderInstance$1R.instances()` it calls
`instanceCreate()` on each `Toolbar$Folder`.
- `FolderInstance.instanceCreate()` calls `waitFinished()` and then reads
`object`. If `object` is still the "uninitialized" marker (`CURRENT`), it
throws the "Cyclic reference" `IOException` (`FolderInstance.java:272-275`). No
real cycle has to be involved; it only means the wait returned before the
toolbar was created.
- `Toolbar$Folder.postCreationTask()` builds each toolbar in an `AWTTask` on
the event dispatch thread. When that task runs, `R.run()` returns immediately
without calling `defaultProcessObjectsFinal()` if `sequence !=
creationSequence`, that is, if a newer `recreate()` of the same folder has
started in the meantime (`FolderInstance.java:690-692`).
- `Toolbar.setUI()` calls `processor.recreate()` (`Toolbar.java:537-543`).
So any UI or look-and-feel refresh that reaches a toolbar while it is being
created for the first time starts a newer creation, and the original task
becomes a no-op.
- A thread that was waiting on the superseded task can then wake up with
`object` still `CURRENT`. That thread throws the "Cyclic reference" exception
and `ToolbarPool` drops the toolbar. Nothing creates the toolbar again later in
the session.
If that is right, the `volatile` change in #3635 fixes cross-thread
visibility, but not a creation task that was superseded. A possible fix would
be to have `waitFinished()`/`instanceCreate()` loop again (wait on the current
`creationTask`) while `object == CURRENT` and the creation sequence has changed.
[messages-toolbar-build-missing.log](https://github.com/user-attachments/files/34414680/messages-toolbar-build-missing.log)
### Language / Project Type / NetBeans Component
_No response_
### How to reproduce
Restart NetBeans and can happen at random.
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
Windows Server 2019 (10.0, amd64)
### JDK
OpenJDK 21.0.12.1+1-LTS (Eclipse Adoptium)
### Apache NetBeans packaging
Apache NetBeans binary zip
### Anything else
**Frequency:** about 2 startups so far.
**Extra plugins:** one third-party plugin is installed, JRebel for NetBeans.
Its only toolbar contribution is one non-lazy action (`Presenter.Toolbar`) in
`Toolbars/Build`, plus a position attribute on an existing `Toolbars/Build`
entry. It does not touch `Toolbars/File`, yet `Toolbars/File` failed the same
way, so the plugin is not required to trigger the bug.
**Related old reports:** Bugzilla 232389 and 234277 (File toolbar missing at
startup with the same message), and NETBEANS-6458.
### Are you willing to submit a pull request?
No
--
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