Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing isEventDispatchThread - it causes problems in headless env #4134

Merged
merged 1 commit into from May 23, 2022

Conversation

JaroslavTulach
Copy link

@JaroslavTulach JaroslavTulach commented May 20, 2022

A colleague of mine reported following error when using Sampler:

Caused by: java.awt.AWTError: Could not create Toolkit: sun.awt.X11.XToolkit
    at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:607)
    at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:583)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.desktop/java.awt.Toolkit.getDefaultToolkit(Toolkit.java:582)
    at java.desktop/java.awt.Toolkit.getEventQueue(Toolkit.java:1494)
    at java.desktop/java.awt.EventQueue.isDispatchThread(EventQueue.java:1086)
    at java.desktop/javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1493)
    at org.netbeans.modules.sampler.Sampler.stopSampling(Sampler.java:232)
    at org.netbeans.modules.sampler.Sampler.stopAndWriteTo(Sampler.java:209)
    at org.netbeans.modules.sampler.Test.stopSampling(Test.java:58)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    ... 1 more

We shouldn't be calling into Swing in a library that is supposed to be used in a headless environment. Removing the (almost useless) check.

With this PR I can build the org-netbeans-modules-sampler.jar and run Test.java as:

/jdk-11/bin/java -cp ~/NetBeansProjects/netbeans/nbbuild/netbeans/platform/modules/org-netbeans-modules-sampler.jar Test.java
Starting processing ...
Processing started
doing work ...
doing work ...
doing work ...
doing work ...
doing work ...
^CRunning shutdown hook.
Stopping sampling ...
Sampling stopped.

while doing the same with d5f29c1 yields the above described error.

@ebarboni ebarboni added the do not merge Don't merge this PR, it is not ready or just demonstration purposes. label May 23, 2022
@ebarboni
Copy link
Contributor

Hi sorry for the delay, but as said in the ML the delivery branches is not accurate. It contains spec version of NetBeans 15. (as well of other master changes). We had a conflig merging delivery to master and I did'nt see the impact.

@neilcsmith-net @JaroslavTulach maybe this PR can be rebase to release140, and we could create a sync PR to get this to master.
I could generate a RC5 and on wednesday I should be able to generate the bits for voting.

@neilcsmith-net
Copy link
Member

@ebarboni syncing release140 with master would be a problem. Best to fix delivery as @matthiasblaesing outlined. Alternatively merge this direct to release140 and @JaroslavTulach can open a second PR for just this change against master. Shouldn't cause a problem ... if the vote goes to plan.

@ebarboni
Copy link
Contributor

sorry @neilcsmith-net I guess the delivery is good now.

@ebarboni
Copy link
Contributor

@JaroslavTulach I guess you have to rebase this PR on the up to date delivery branch.

@ebarboni ebarboni merged commit 81a902f into apache:delivery May 23, 2022
@ebarboni ebarboni removed the do not merge Don't merge this PR, it is not ready or just demonstration purposes. label May 24, 2022
@ebarboni ebarboni added this to the NB14 milestone May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants