GitHub user matthiasblaesing added a comment to the discussion: Windows clipboard issues discussion
This might be an option: ```java package eu.doppelhelix.test.clipboardreproducer; import java.awt.Toolkit; import java.awt.datatransfer.FlavorEvent; import java.awt.datatransfer.FlavorListener; import java.awt.datatransfer.StringSelection; import java.lang.System.Logger; import java.lang.System.Logger.Level; import javax.swing.SwingUtilities; public class Clipboardreproducer { private static final Logger LOG = System.getLogger(Clipboardreproducer.class.getName()); public static void main(String[] args) throws InterruptedException { SwingUtilities.invokeLater(() -> { Toolkit.getDefaultToolkit().getSystemClipboard().addFlavorListener(new FlavorListener() { @Override public void flavorsChanged(FlavorEvent e) { LOG.log(Level.INFO, "Flavor Changed: {0} // {1}", e, SwingUtilities.isEventDispatchThread()); } }); }); // Copy operation one: copy from EDT Runnable copy = new Runnable() { public void run() { try { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("Test"), null); LOG.log(Level.INFO, "Copy 1"); } catch (IllegalStateException ex) { LOG.log(Level.ERROR, "Failed to invoke copy (1)", ex); } SwingUtilities.invokeLater(this); } }; SwingUtilities.invokeLater(copy); // Copy operation two: Simulate secondary source new Thread() { @Override public void run() { while (true) { try { Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection("Test"), null); LOG.log(Level.INFO, "Copy 2"); } catch (IllegalStateException ex) { LOG.log(Level.ERROR, "Failed to invoke copy (2)", ex); } } } }.start(); Thread.sleep(60 * 1000); } } ``` With a JDK built with assertions enabled (fastdebug), this reliably gets me the assertion. The underlying problem is the same, two threads enter the critical region (call between `openClipboard` and `closeClipboard` together). GitHub link: https://github.com/apache/netbeans/discussions/7051#discussioncomment-12742018 ---- This is an automatically sent email for notifications@netbeans.apache.org. To unsubscribe, please send an email to: notifications-unsubscr...@netbeans.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org For additional commands, e-mail: notifications-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists