You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/05/20 12:25:56 UTC

[GitHub] [netbeans] JaroslavTulach opened a new pull request, #4134: Removing isEventDispatchThread - it causes problems in headless env

JaroslavTulach opened a new pull request, #4134:
URL: https://github.com/apache/netbeans/pull/4134

   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.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] ebarboni merged pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
ebarboni merged PR #4134:
URL: https://github.com/apache/netbeans/pull/4134


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] ebarboni commented on pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
ebarboni commented on PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#issuecomment-1134551797

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


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a diff in pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on code in PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#discussion_r878629654


##########
platform/sampler/src/org/netbeans/modules/sampler/Sampler.java:
##########
@@ -227,7 +226,6 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
             if (cancel || samples < 1) {
                 return;
             }
-            if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT");  //NOI18N

Review Comment:
   Since https://github.com/apache/netbeans/pull/4052 the `InternalSampler`constructor shall throw `LinkageError` and rather `StandaloneSampler` shall be used in a non-NetBeans environment. `InternalSampler` is intended only for usage in NetBeans/Swing application. 
   
   That actually means we can move the check into `InternalSampler`: https://github.com/apache/netbeans/commit/b142bbce7d656c1319d535cf918bf2ffab85bae7 - thank you for your review.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] 4e6 commented on a diff in pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
4e6 commented on code in PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#discussion_r878102153


##########
platform/sampler/src/org/netbeans/modules/sampler/Sampler.java:
##########
@@ -227,7 +226,6 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
             if (cancel || samples < 1) {
                 return;
             }
-            if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT");  //NOI18N

Review Comment:
   There are also other Swing usages that should be treated in a similar way
   
   ```bash
   $ rg 'isDispatchThread' .
   ./src/main/java/org/netbeans/modules/sampler/InternalSampler.java
   174:        if (EventQueue.isDispatchThread()) {
   183:        if (EventQueue.isDispatchThread()) {
   192:        if (EventQueue.isDispatchThread()) {
   ```



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] ebarboni commented on pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
ebarboni commented on PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#issuecomment-1134549790

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


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a diff in pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on code in PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#discussion_r878629654


##########
platform/sampler/src/org/netbeans/modules/sampler/Sampler.java:
##########
@@ -227,7 +226,6 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
             if (cancel || samples < 1) {
                 return;
             }
-            if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT");  //NOI18N

Review Comment:
   Since https://github.com/apache/netbeans/pull/4052 the `InternalSampler`constructor shall throw `LinkageError` and rather `StandaloneSampler` shall be used in a non-NetBeans environment. `InternalSampler` is intended only for usage in NetBeans/Swing application.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] neilcsmith-net commented on pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#issuecomment-1134514995

   @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.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] 4e6 commented on a diff in pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
4e6 commented on code in PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#discussion_r878102153


##########
platform/sampler/src/org/netbeans/modules/sampler/Sampler.java:
##########
@@ -227,7 +226,6 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
             if (cancel || samples < 1) {
                 return;
             }
-            if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT");  //NOI18N

Review Comment:
   There are also other AWT usages that should be treated in a similar way
   
   ```bash
   $ rg 'isDispatchThread' .
   ./src/main/java/org/netbeans/modules/sampler/InternalSampler.java
   174:        if (EventQueue.isDispatchThread()) {
   183:        if (EventQueue.isDispatchThread()) {
   192:        if (EventQueue.isDispatchThread()) {
   ```



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien commented on a diff in pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
mbien commented on code in PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#discussion_r878100330


##########
platform/sampler/src/org/netbeans/modules/sampler/Sampler.java:
##########
@@ -227,7 +226,6 @@ private synchronized void stopSampling(boolean cancel, DataOutputStream dos) {
             if (cancel || samples < 1) {
                 return;
             }
-            if (SwingUtilities.isEventDispatchThread()) throw new IllegalStateException("sampling cannot be stopped from EDT");  //NOI18N

Review Comment:
   consider `!GraphicsEnvironment.isHeadless() && SwingUtilities.isEventDispatchThread()`
   
   it wouldn't surprise me if this has been already extracted into a utility somewhere since this looks to me like a common check.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] ebarboni commented on pull request #4134: Removing isEventDispatchThread - it causes problems in headless env

Posted by GitBox <gi...@apache.org>.
ebarboni commented on PR #4134:
URL: https://github.com/apache/netbeans/pull/4134#issuecomment-1134387861

   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. 


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists