JDK-8187304 : [macosx] Drag and drop not working
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8u72
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: os_x
  • CPU: x86
  • Submitted: 2017-08-30
  • Updated: 2017-09-07
  • Resolved: 2017-09-07
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
macOS Sierra 10.12.6

A DESCRIPTION OF THE PROBLEM :
This error is already available under JDK-8173803. But this error was closed, because of a missing testapplication. This testapplication is now available. (Addidtional information is available under JDK-8173803.)

Drag And Drop from one Java window to another does not work. 

If an object is dragged from one window to another window via drag and drop, the drag and drop action is not completed. The java application thinks it is still in the drag and drop. If one tries another drag and drop action an exception will be thrown: 'java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress'. 

It is therefore no longer possible to drag and drop objects in this application. The problem occurs always at the transition between the drag source window and the drag target window. Working with the application is still possible. After a restart of the application, Drag And Drop will work again.

Furthermore, the system Dock becomes disabled and does not react to mouse events - it isn't possible to switch to other windows by clicking their Dock icons. Popup menu on the Dock doesn't work either. Switching to other apps with keyboard works fine though. After quitting the application in broken drag mode, the Dock becomes responsive again. 

The Error occurs in: CDragSourceContextPeer.doDragging(long). This is a native method, which is implemented in the JRE. The Callstack of the corresponding thread:

Thread [Thread-29]
   CDragSourceContextPeer.doDragging(long) line: not available [native method]
   CDragSourceContextPeer.access$100(CDragSourceContextPeer, long) line 49
   CDragSourceContextPeer$1.run() line: 170

This error is similar to the reported error JDK-7177144 but in this case it is a genuine Java application and not netbeans. Maybe the error JDK-7185258 is the reason for this problem.

The Stacktrace of the threads (suspended in eclipse - but error occurs outside IDE as well):

ApplicationCore18 [Java Application]	
	com.heidelberg.signa.main.SignaMain at localhost:60994 (Suspended)	
		Daemon System Thread [Signal Dispatcher] (Suspended)	
		Daemon System Thread [Finalizer] (Suspended)	
		Daemon System Thread [Reference Handler] (Suspended)	
		Daemon System Thread [JavaFX Application Thread] (Suspended)	
			LWCToolkit.doAWTRunLoopImpl(long, boolean, boolean) line: not available [native method]	
			LWCToolkit.doAWTRunLoop(long, boolean) line: 825	
			CToolkitThreadBlockedHandler.enter() line: 46	
			CDropTargetContextPeer(SunDropTargetContextPeer).postDropTargetEvent(Component, int, int, int, int, long[], long, int, boolean) line: 584	
			CDropTargetContextPeer.postDropTargetEvent(Component, int, int, int, int, long[], long, int, boolean) line: 165	
			CDropTargetContextPeer(SunDropTargetContextPeer).handleExitMessage(Component, long) line: 359	
		Daemon System Thread [process reaper] (Suspended)	
		Daemon Thread [Timer-0] (Suspended)	
		System Thread [AWT-Shutdown] (Suspended)	
		Thread [AWT-EventQueue-0] (Suspended)	
			Unsafe.park(boolean, long) line: not available [native method]	
			LockSupport.park(Object) line: 175	
			AbstractQueuedSynchronizer$ConditionObject.await() line: 2039	
			EventQueue.getNextEvent() line: 554	
			EventDispatchThread.pumpOneEventForFilters(int) line: 170	
			EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 116	
			EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 105	
			EventDispatchThread.pumpEvents(int, Conditional) line: 101	
			EventDispatchThread.pumpEvents(Conditional) line: 93	
			EventDispatchThread.run() line: 82	
		Daemon System Thread [Java2D Queue Flusher] (Suspended)	
			waiting for: OGLRenderQueue$QueueFlusher  (id=33)	
			Object.wait(long) line: not available [native method]	
			OGLRenderQueue$QueueFlusher.run() line: 203	
		Daemon System Thread [Java2D Disposer] (Suspended)	
			waiting for: ReferenceQueue$Lock  (id=114)	
			Object.wait(long) line: not available [native method]	
			ReferenceQueue<T>.remove(long) line: 143	
			ReferenceQueue<T>.remove() line: 164	
			Disposer.run() line: 148	
			Thread.run() line: 745	
		Daemon Thread [QuantumRenderer-0] (Suspended)	
		Daemon Thread [Thread-6] (Suspended)	
		Daemon Thread [Thread-7] (Suspended)	
		Daemon System Thread [Prism Font Disposer] (Suspended)	
		Thread [ApplicationAction-Thread] (Suspended)	
		Thread [Thread-9] (Suspended)	
		Thread [Timer-1] (Suspended)	
		Daemon Thread [Timer runner-1,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [TransferQueueBundler,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [unicast receiver,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [multicast receiver,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Daemon Thread [WatchThread - 1033638837] (Suspended)	
		Thread [AutoGang] (Suspended)	
		Daemon Thread [FolderWatcher - 640808588] (Suspended)	
		Daemon System Thread [TimerQueue] (Suspended)	
		Daemon Thread [SwingWorker-pool-6-thread-1] (Suspended)	
		Thread [SignaPDF-(1)] (Suspended)	
		Thread [SignaPDF-(2)] (Suspended)	
		Thread [SignaPDF-(3)] (Suspended)	
		Thread [SignaPDF-(0)] (Suspended)	
		Thread [SignaPDF-(4)] (Suspended)	
		Daemon Thread [Thread-21] (Suspended)	
		Daemon System Thread [RMI TCP Accept-0] (Suspended)	
		System Thread [RMI Reaper] (Suspended)	
		Daemon System Thread [GC Daemon] (Suspended)	
		Daemon System Thread [RMI Scheduler(0)] (Suspended)	
		Thread [DestroyJavaVM] (Suspended)	
		Thread [RMI-Rebind-Thread] (Suspended)	
		Thread [Doc_1_1485941334042-Thread] (Suspended)	
		Thread [DirectImageManager(0)] (Suspended)	
		Thread [DirectImageManager(1)] (Suspended)	
		Thread [DirectImageManager(2)] (Suspended)	
		Thread [DirectImageManager(3)] (Suspended)	
		Thread [DirectImageManager(4)] (Suspended)	
		Daemon Thread [SwingWorker-pool-6-thread-2] (Suspended)	
		Daemon Thread [Timer-2,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
		Thread [Thread-29] (Suspended)	
			CDragSourceContextPeer.doDragging(long) line: not available [native method]	
			CDragSourceContextPeer.access$100(CDragSourceContextPeer, long) line: 49	
			CDragSourceContextPeer$1.run() line: 170	
		Daemon Thread [Timer-3,Remote_Update_Channel_Signa_Station-18_kie-haasetim-mc.ppe.kie.de.heidelberg.com,kie-haasetim-mc-59142] (Suspended)	
	/Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home/bin/java (01.02.2017, 10:27:42)	





STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
A Java appliction with two windows. Drag from one window and drop to the other window. In some cases the drag and drop will not complete successfully. 

To reproduce it is necessary to drag and drop the object multiple times. After that it will occur while dragging the object at the transition from the dragsource window to the dragtarget window.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The dragging should complete successfully.
ACTUAL -
The dragging hangs and drag and drop is no longer possible after the error occurs.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
After the error occurs the next drag and drop will throw the following exception: 'java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress'.

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.LookAndFeel;
import javax.swing.TransferHandler;
import javax.swing.UIManager;
import javax.swing.plaf.metal.MetalLookAndFeel;

public class DnDErrorMain
{

    public DnDErrorMain()
    {
        try
        {
            final LookAndFeel laf = new MetalLookAndFeel();
            UIManager.setLookAndFeel(laf);
        }
        catch (final Exception ex)
        {
            System.err.println("Could not install DesktopLookAndFeel look and feel: " + ex);
            ex.printStackTrace();
            Thread.dumpStack();
        }
    }
    
    private void createAndShowGUI()
    {
        JFrame.setDefaultLookAndFeelDecorated(true);

        final JFrame treeFrame = new JFrame("Tree Frame");
        treeFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        treeFrame.setBounds(100, 100, 800, 1200);
        treeFrame.setLayout(new BorderLayout());
        treeFrame.getContentPane().add(createTreePanel(), BorderLayout.CENTER);
        treeFrame.setVisible(true);

    
        final JFrame paneFrame = new JFrame("Drop Frame");
        paneFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        paneFrame.setBounds(800, 150, 800, 1200);
        paneFrame.setLayout(new BorderLayout());
        paneFrame.getContentPane().add(createDropPanel(), BorderLayout.CENTER);
        paneFrame.setVisible(true);
    }


    private JComponent createDropPanel()
    {
        JPanel dropPanel = new JPanel(new BorderLayout())
                {
                    @Override
                    protected void paintComponent(Graphics g)
                    {
                        try
                        {
                            Thread.sleep(200);
                        }
                        catch( InterruptedException e )
                        {
                            e.printStackTrace();
                        }
                        super.paintComponent(g);
                    }
                };

        dropPanel.add(new JLabel("DropPanel"), BorderLayout.NORTH);

        dropPanel.setTransferHandler(new TransferHandler()
        {
            @Override
            public boolean canImport(TransferSupport support)
            {
                dropPanel.repaint();
                return true;
            }
        });

        return dropPanel;
    }

    private JComponent createTreePanel()
    {
        JPanel treePanel = new JPanel(new BorderLayout());
        JTree tree = new JTree();
        tree.setDragEnabled(true);
        treePanel.add(tree, BorderLayout.CENTER);
        
        return treePanel;
    }

    public static void main(String[] args)
    {
        final DnDErrorMain main = new DnDErrorMain();
        EventQueue.invokeLater(() -> main.createAndShowGUI());
    }

}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Close the application and restart it. After restart drag and drop works again.


Comments
This is a duplicate of JDK-8173803 with additional information including a test case. Closing this as duplicate while reopening the original report, with verified results and added test case.
07-09-2017