JDK-8187781 : "InvalidDnDOperationException: Drag and drop in progress" while running javafx application with option -Djavafx.embed.singleThread=true
  • Type: Bug
  • Component: javafx
  • Sub-Component: swing
  • Affected Version: 8,9,10
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: generic
  • Submitted: 2017-09-21
  • Updated: 2020-01-31
  • Resolved: 2017-09-26
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.
JDK 10 JDK 8
10Fixed 8u162Fixed
Related Reports
Relates :  
Description
Problem Description: 
On second drag it is throwing "Exception in thread "JavaFX Application Thread" java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress"

Steps to Reproduce:
Run the attached program SwingFx.java with -Djavafx.embed.singleThread=true. On second drag we will get the exception.

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

Stack trace: 
Exception in thread "JavaFX Application Thread" java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress
        at java.desktop/sun.awt.dnd.SunDragSourceContextPeer.setDragDropInProgress(SunDragSourceContextPeer.java:357)
        at java.desktop/java.awt.dnd.DragSource.startDrag(DragSource.java:303)
        at java.desktop/java.awt.dnd.DragSource.startDrag(DragSource.java:422)
        at java.desktop/java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:238)
        at SwingFx$2$1.dragGestureRecognized(SwingFx.java:71)
        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 javafx.swing/javafx.embed.swing.SwingFXUtils.runOnEDTAndWait(SwingFXUtils.java:294)
        at javafx.swing/javafx.embed.swing.FXDnD.lambda$new$2(FXDnD.java:226)
        at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
        at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
        at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
        at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
        at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
        at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
        at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
        at javafx.graphics/javafx.scene.Scene$DnDGesture.fireEvent(Scene.java:3052)
        at javafx.graphics/javafx.scene.Scene$DnDGesture.process(Scene.java:3131)
        at javafx.graphics/javafx.scene.Scene$DnDGesture.access$8400(Scene.java:3028)
        at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3892)
        at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604)
        at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
        at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
        at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
        at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoopImpl(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._enterNestedEventLoop(WinApplication.java:199)
        at javafx.graphics/com.sun.glass.ui.Application.enterNestedEventLoop(Application.java:511)
        at javafx.graphics/com.sun.glass.ui.EventLoop.enter(EventLoop.java:107)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.enterNestedEventLoop(QuantumToolkit.java:590)
        at javafx.swing/com.sun.javafx.embed.swing.SwingFXUtilsImpl$FwSecondaryLoop.lambda$enter$0(SwingFXUtilsImpl.java:49)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:440)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:430)
        at javafx.swing/com.sun.javafx.embed.swing.SwingFXUtilsImpl$FwSecondaryLoop.enter(SwingFXUtilsImpl.java:48)
        at java.desktop/java.awt.EventQueue$FwSecondaryLoopWrapper.enter(EventQueue.java:1027)
        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 SwingFx$2$1.dragGestureRecognized(SwingFx.java:71)
        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 javafx.swing/javafx.embed.swing.SwingFXUtils.runOnEDTAndWait(SwingFXUtils.java:294)
        at javafx.swing/javafx.embed.swing.FXDnD.lambda$new$2(FXDnD.java:226)
        at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
        at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
        at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
        at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
        at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
        at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
        at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
        at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
        at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
        at javafx.graphics/javafx.scene.Scene$DnDGesture.fireEvent(Scene.java:3052)
        at javafx.graphics/javafx.scene.Scene$DnDGesture.process(Scene.java:3131)
        at javafx.graphics/javafx.scene.Scene$DnDGesture.access$8400(Scene.java:3028)
        at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3892)
        at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1300(Scene.java:3604)
        at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1874)
        at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2613)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
        at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
        at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
        at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
        at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:172)
        at java.base/java.lang.Thread.run(Thread.java:844)

Comments
+1 on the 8u-dev backport.
06-10-2017

The patch does not apply cleanly as the order of imports are different in 8udev. New 8udev webrev http://cr.openjdk.java.net/~psadhukhan/fx/8187781/8udev/webrev.00/
06-10-2017

Changeset: 48181ab479ee Author: psadhukhan Date: 2017-09-26 14:38 +0530 URL: http://hg.openjdk.java.net/openjfx/10-dev/rt/rev/48181ab479ee
26-09-2017

looks fine
26-09-2017

For singleThread=true, it seems there is no need of using Secondary loop as the dispatch is happening in the same thread as user drag event, so drag event is not received when thread is waiting in secondary loop. Proposed fix is not to use secondary loop mechanism for singleThread feature. http://cr.openjdk.java.net/~psadhukhan/fx/8187781/webrev.00/ Request to review the fix.
22-09-2017