JDK-8187778 : "IllegalStateException: Cannot start drag and drop outside of DRAG_DETECTED event handler" on drag and drop
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 8,9,10
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: windows
  • CPU: generic
  • Submitted: 2017-09-21
  • Updated: 2018-09-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
Problem Description:
On doing multiple drag and drop it ends up with Exception:
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Cannot start drag and drop outside of DRAG_DETECTED event handler

If we do some action after the initial exception more exception are coming.
Exception in thread "AWT-EventQueue-0" java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress

Exception in thread "JavaFX Application Thread" drag recognized...java.lang.IllegalArgumentException: Key already associated with a running event loop: javafx.embed.swing.FXDnD@e4f5588

Steps to reproduce:
Run the attached test case SwingFXDnDTest.java
Do multiple drag and drop as shown in the attached video:drag_and_drop.mp4

Issue is reproducible in JDK8, JDK9 build 181 , JDK10 build 24.

There are small difference in the exception stack trace in JDK8 and 9(9 and 10 is same). So attached the stack trace for JDK 8 and 9. 


Comments
I tried with 10b26 as well but I am not able to get either NPE or IllegalStateException.
10-10-2017

I tried with JDK10 b26 and end up with new exception: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at java.desktop/javax.swing.TransferHandler$DropHandler.handleDrag(TransferHandler.java:1458) at java.desktop/javax.swing.TransferHandler$DropHandler.dragOver(TransferHandler.java:1496) at java.desktop/java.awt.dnd.DropTarget.dragOver(DropTarget.java:379) at java.desktop/javax.swing.TransferHandler$SwingDropTarget.dragOver(TransferHandler.java:1250) at javafx.swing/javafx.embed.swing.FXDnD$FXDropTargetContextPeer.lambda$postDropTargetEvent$0(FXDnD.java:478) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766) at java.desktop/java.awt.EventQueue.access$500(EventQueue.java:97) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:717) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:711) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:89) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:736) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:188) at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235) at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233) at javafx.swing/javafx.embed.swing.FXDnD$FXDragSourceContextPeer.startDrag(FXDnD.java:315) at java.desktop/sun.awt.dnd.SunDragSourceContextPeer.startDrag(SunDragSourceContextPeer.java:134) at java.desktop/java.awt.dnd.DragSource.startDrag(DragSource.java:317) at java.desktop/java.awt.dnd.DragSource.startDrag(DragSource.java:422) at java.desktop/java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:238) at SwingFXDnDTest$4$1.dragGestureRecognized(SwingFXDnDTest.java:99) at java.desktop/java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(DragGestureRecognizer.java:361) at javafx.swing/javafx.embed.swing.FXDnD$FXDragGestureRecognizer.fireEvent(FXDnD.java:190) at javafx.swing/javafx.embed.swing.FXDnD$FXDragGestureRecognizer.access$1000(FXDnD.java:139) at javafx.swing/javafx.embed.swing.FXDnD.fireEvent(FXDnD.java:200) at javafx.swing/javafx.embed.swing.FXDnD.lambda$new$1(FXDnD.java:226) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:766) at java.desktop/java.awt.EventQueue.access$500(EventQueue.java:97) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:717) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:711) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:89) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:736) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
10-10-2017

I tried dragdrop with jdk10b25 for several minutes and I am not able to reproduce this exception.
06-10-2017

No, I reproduced with simple java command "java SwingFXDnDTest" on JDK10 build 24, JDK9 and JDK8. But you have to do drag and drop for some time as shown in video. I couldn't identify what is the exact sequence.
22-09-2017

I am not able to reproduce this exception even after multiple drag&drop with jdk10 built with jfx10.
22-09-2017

[~akolarkunnu] Does this bug require -Djavafx.embed.singleThread=true to reproduce?
22-09-2017