Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8262446

DragAndDrop hangs on Windows

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b01
    • Introduced In Version:
    • Resolved In Build:
      b13
    • CPU:
      x86_64
    • OS:
      windows

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        Windows x64

        A DESCRIPTION OF THE PROBLEM :
        Dragging files from Windows Explorer to a Java application hangs. Not each time but very often.
        I have implemented a DroppableDesktopPane (see source code) and dropping a file on that DesktopPane sometimes hangs (very often).
        This issue is new with JDK 15.0.2 and JDK 11.0.10. It is working fine with the previous release JDK 15.0.1 and JDK 11.0.9.

        REGRESSION : Last worked in version 15.0.1, 11.0.9

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Drag a file on the DroppableDesktopPane.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        No hanging
        ACTUAL -
        Application hangs. Stack trace:
        UPSEClient15 [Java Application]
        StartUpFrame at localhost:64016 (Suspended)
        Thread [Timer-0] (Suspended)
        waiting for: TaskQueue (id=40)
        Object.wait(long) line: not available [native method]
        TaskQueue(Object).wait() line: 321
        TimerThread.mainLoop() line: 527
        TimerThread.run() line: 506
        Thread [AWT-EventQueue-0] (Suspended)
        WInputMethod.openCandidateWindow(WComponentPeer, int, int) line: not available [native method]
        WInputMethod$1.run() line: 622
        InvocationEvent.dispatch() line: 316
        EventQueue.dispatchEventImpl(AWTEvent, Object) line: 770
        EventQueue$4.run() line: 721
        EventQueue$4.run() line: 715
        AccessController.executePrivileged(PrivilegedAction<T>, AccessControlContext, Class<?>) line: 753
        AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: 391
        ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 85
        ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext) line: 95
        EventQueue$5.run() line: 745
        EventQueue$5.run() line: 743
        AccessController.executePrivileged(PrivilegedAction<T>, AccessControlContext, Class<?>) line: 753
        AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: 391
        ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 85
        EventQueue.dispatchEvent(AWTEvent) line: 742
        EventDispatchThread.pumpOneEventForFilters(int) line: 203
        EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 124
        EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 113
        EventDispatchThread.pumpEvents(int, Conditional) line: 109
        EventDispatchThread.pumpEvents(Conditional) line: 101
        EventDispatchThread.run() line: 90
        Thread [DestroyJavaVM] (Suspended)
        Daemon Thread [mysql-cj-abandoned-connection-cleanup] (Suspended)
        waiting for: ReferenceQueue$Lock (id=38)
        Object.wait(long) line: not available [native method]
        ReferenceQueue<T>.remove(long) line: 155
        AbandonedConnectionCleanupThread.run() line: 91
        ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1130
        ThreadPoolExecutor$Worker.run() line: 630
        Thread.run() line: 832
        Thread [Thread-2] (Suspended)
        owns: BufferedInputStream (id=39)
        SocketDispatcher.read0(FileDescriptor, long, int) line: not available [native method]
        SocketDispatcher.read(FileDescriptor, long, int) line: 46
        NioSocketImpl.tryRead(FileDescriptor, byte[], int, int) line: 261
        NioSocketImpl.implRead(byte[], int, int) line: 312
        NioSocketImpl.read(byte[], int, int) line: 350
        NioSocketImpl$1.read(byte[], int, int) line: 803
        Socket$SocketInputStream.read(byte[], int, int) line: 981
        BufferedInputStream.fill() line: 244
        BufferedInputStream.read() line: 263
        DataInputStream.readInt() line: 391
        TCPThread.run() line: 311
        Daemon System Thread [Reference Handler] (Suspended)
        Reference<T>.waitForReferencePendingList() line: not available [native method]
        Reference<T>.processPendingReferences() line: 241
        Reference$ReferenceHandler.run() line: 213
        Daemon System Thread [Finalizer] (Suspended)
        waiting for: ReferenceQueue$Lock (id=41)
        Object.wait(long) line: not available [native method]
        ReferenceQueue<T>.remove(long) line: 155
        ReferenceQueue<T>.remove() line: 176
        Finalizer$FinalizerThread.run() line: 170
        Daemon System Thread [Signal Dispatcher] (Suspended)
        Daemon System Thread [Attach Listener] (Suspended)
        Daemon System Thread [Common-Cleaner] (Suspended)
        waiting for: ReferenceQueue$Lock (id=42)
        Object.wait(long) line: not available [native method]
        ReferenceQueue<T>.remove(long) line: 155
        CleanerImpl.run() line: 148
        InnocuousThread(Thread).run() line: 832
        InnocuousThread.run() line: 134
        Daemon System Thread [Notification Thread] (Suspended)
        Daemon System Thread [Java2D Disposer] (Suspended)
        waiting for: ReferenceQueue$Lock (id=43)
        Object.wait(long) line: not available [native method]
        ReferenceQueue<T>.remove(long) line: 155
        ReferenceQueue<T>.remove() line: 176
        Disposer.run() line: 144
        Thread.run() line: 832
        System Thread [AWT-Shutdown] (Suspended)
        waiting for: Object (id=44)
        Object.wait(long) line: not available [native method]
        Object.wait() line: 321
        AWTAutoShutdown.run() line: 291
        Thread.run() line: 832
        Daemon System Thread [AWT-Windows] (Suspended)
        WToolkitThreadBlockedHandler.startSecondaryEventLoop() line: not available [native method]
        WToolkitThreadBlockedHandler.enter() line: 508
        WDropTargetContextPeer(SunDropTargetContextPeer).postDropTargetEvent(Component, int, int, int, int, long[], long, int, boolean) line: 593
        WDropTargetContextPeer(SunDropTargetContextPeer).handleEnterMessage(Component, int, int, int, int, long[], long) line: 302
        WToolkit.eventLoop() line: not available [native method]
        WToolkit.run() line: 361
        Thread.run() line: 832
        Daemon System Thread [TimerQueue] (Suspended)
        Unsafe.park(boolean, long) line: not available [native method]
        LockSupport.park() line: 341
        AbstractQueuedSynchronizer$ConditionNode.block() line: 505
        ForkJoinPool.managedBlock(ForkJoinPool$ManagedBlocker) line: 3137
        AbstractQueuedSynchronizer$ConditionObject.await() line: 1614
        DelayQueue<E>.take() line: 217
        TimerQueue.run() line: 171
        Thread.run() line: 832
        C:\Program Files\Java\jdk-15.0.2\bin\javaw.exe (23 Feb 2021, 06:27:09)


        ---------- BEGIN SOURCE ----------
        /*
        A JDesktopPane which support Drag&Drop.
        */

        import java.io.*;
        import java.awt.dnd.*;
        import java.awt.datatransfer.*;
        import java.util.*;


        public class DroppableDesktopPane extends javax.swing.JDesktopPane implements DropTargetListener
        {
        private static final long serialVersionUID = 1L;

        DropTarget dropTarget;
            MainFrame mFrame;

            public DroppableDesktopPane(MainFrame mf)
            {
                super();
                mFrame = mf;
                dropTarget = new DropTarget(this, this);
            }


            public void dragEnter(DropTargetDragEvent e)
        {
        e.acceptDrag(DnDConstants.ACTION_COPY);
        }

        public void dragExit(DropTargetEvent e)
        {

        }

        public void dragOver(DropTargetDragEvent e)
        {
        e.acceptDrag(DnDConstants.ACTION_COPY);
        }

        public void dropActionChanged(DropTargetDragEvent e)
        {
        e.acceptDrag(DnDConstants.ACTION_COPY);
        }

        public synchronized void drop(DropTargetDropEvent e)
        {
        try
        {
        DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
        Transferable tr = e.getTransferable();

        if (tr.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
        {
        e.acceptDrop(DnDConstants.ACTION_COPY);
        java.util.List<?> fileList = (java.util.List<?>)tr.getTransferData(DataFlavor.javaFileListFlavor);

        Iterator<?> it = fileList.iterator();
        while (it.hasNext())
        {
        File file = (File)it.next();
        if (file != null)
        mFrame.doOpen(file);
        }
        e.getDropTargetContext().dropComplete(true);
        }
        else if (tr.isDataFlavorSupported(uriListFlavor)) // Linux java bug 4899516: drop doesn't give a list of file
        {
        e.acceptDrop(DnDConstants.ACTION_COPY);
        String data = (String)tr.getTransferData(uriListFlavor);
        java.util.List<?> fileList = textURIListToFileList(data);

        Iterator<?> it = fileList.iterator();
        while (it.hasNext())
        {
        File file = (File)it.next();
        // open the file
        }
        e.getDropTargetContext().dropComplete(true);
        }
        else
        e.rejectDrop();
        }
        catch (IOException exio)
        {
        e.rejectDrop();
        }
        catch (UnsupportedFlavorException ex)
        {
        e.rejectDrop();
        }
        catch (ClassNotFoundException ex2)
        {
        e.rejectDrop();
        }
        }


        private static java.util.List<File> textURIListToFileList(String data)
        {
        java.util.List<File> list = new java.util.ArrayList<File>(1);
        for (java.util.StringTokenizer st = new java.util.StringTokenizer(data, "\r\n"); st.hasMoreTokens();)
        {
        String s = st.nextToken();
        if (s.startsWith("#"))
        {
        // the line is a comment (as per the RFC 2483)
        continue;
        }
        try
        {
        java.net.URI uri = new java.net.URI(s);
        java.io.File file = new java.io.File(uri);
        list.add(file);
        } catch (java.net.URISyntaxException e)
        {
        // malformed URI
        } catch (IllegalArgumentException e)
        {
        // the URI is not a valid 'file:' URI
        }
        }
        return list;
        }

        }

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

        FREQUENCY : often


          Attachments

            Issue Links

              Activity

                People

                Assignee:
                dmarkov Dmitry Markov
                Reporter:
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                10 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: