<Swing Dev> JDK-8023043 : Clipboard.getAvailableDataFlavors: Comparison method violates contract

Alexander Scherbatiy alexandr.scherbatiy at oracle.com
Fri May 8 12:38:06 UTC 2015


   Hi Jason,

  Please, file it as a new issue in http://bugreport.java.com/bugreport

   Thanks,
   Alexandr.

On 5/7/2015 11:08 PM, Jason Mehrens wrote:
> Anton,
>
>
> I finally caught this error in production.  I patched our code to launch a JVM (with mergesort) using your test case, modifed to output the JVM version followed by the output when this error occurs.  The output is as follows:
>
>
>
> ==============================================================================
>
> 1.7.0_80-b15
>
> java.awt.datatransfer.DataFlavor[mimetype=application/x-java-serialized-object;representationclass=java.lang.String]
>
> java.awt.datatransfer.DataFlavor[mimetype=application/x-java-text-encoding;representationclass=[B]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.Reader]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.lang.String]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.CharBuffer]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[C]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=unicode]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-16]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-8]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-8]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-8]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16BE]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16BE]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-16BE]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=UTF-16LE]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=UTF-16LE]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=UTF-16LE]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=ISO-8859-1]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=ISO-8859-1]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=ISO-8859-1]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=windows-1252]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=windows-1252]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=windows-1252]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.io.InputStream;charset=US-ASCII]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=java.nio.ByteBuffer;charset=US-ASCII]
>
> java.awt.datatransfer.DataFlavor[mimetype=text/plain;representationclass=[B;charset=US-ASCII]
>
>   ==================================================================================
>
>
>
> Jason
>
>
>
> ----------------------------------------
>> From: jason_mehrens at hotmail.com
>> To: anton.nashatyrev at oracle.com
>> Date: Wed, 22 Apr 2015 14:59:26 -0500
>> CC: swing-dev at openjdk.java.net
>> Subject: Re: <Swing Dev> JDK-8023043 : Clipboard.getAvailableDataFlavors: Comparison method violates contract
>>
>> Anton,
>>
>>
>> Thanks for looking at this. Sorry I don't have a test case to give you yet. For sure the machines are using JDK7u80 that are reproducing the error. The common case is that the user is copying text from an email client and then pasting it in to a JTextField. So I imagine that the content type of email is a factor in producing this issue.
>>
>>
>> What I'll do is convert your ClipboardDump into the codebase so that I can just log that information as soon as it happens. We'll see how long it takes to catch this fish.
>>
>>
>> Thanks,
>>
>>
>> Jason
>>
>>
>>
>>
>>
>> ----------------------------------------
>>> Date: Wed, 22 Apr 2015 17:06:10 +0300
>>> From: anton.nashatyrev at oracle.com
>>> To: jason_mehrens at hotmail.com
>>> CC: swing-dev at openjdk.java.net
>>> Subject: Re: <Swing Dev> JDK-8023043 : Clipboard.getAvailableDataFlavors: Comparison method violates contract
>>>
>>> Hi Jason,
>>>
>>> I've commented in the bug report:
>>>
>>> Couldn't reproduce locally.
>>> Please next time the problem is reproduced on your side, run the small
>>> program below and attach its output to this bug (or file a new one).
>>> Make sure NOT using the system clipboard from the moment of exception
>>> till running the test program.
>>>
>>> import java.awt.*;
>>> import java.awt.datatransfer.DataFlavor;
>>>
>>> public class ClipboardDump {
>>> public static void main(String[] args) {
>>> System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
>>>
>>> DataFlavor[] dataFlavors =
>>> Toolkit.getDefaultToolkit().getSystemClipboard().
>>> getAvailableDataFlavors();
>>>
>>> for (DataFlavor df: dataFlavors) {
>>> System.out.println(df);
>>> }
>>> }
>>> }
>>>
>>> Please also make sure you are running 7u80 (not an earlier version)
>>> since the Comparator fix was integrated to 7u80
>>>
>>> Thanks!
>>> Anton.
>>> On 21.04.2015 17:29, Jason Mehrens wrote:
>>>> Hello Swing-Dev,
>>>>
>>>>
>>>>
>>>> Recently we have updated to JDK7u80 and have noticed a pattern of users generating the following error:
>>>>
>>>>
>>>>
>>>> ==================
>>>>
>>>> java.lang.IllegalArgumentException: Comparison method violates its general contract!
>>>>
>>>> at java.util.TimSort.mergeHi(Unknown Source)
>>>>
>>>> at java.util.TimSort.mergeAt(Unknown Source)
>>>>
>>>> at java.util.TimSort.mergeCollapse(Unknown Source)
>>>>
>>>> at java.util.TimSort.sort(Unknown Source)
>>>>
>>>> at java.util.TimSort.sort(Unknown Source)
>>>>
>>>> at java.util.Arrays.sort(Unknown Source)
>>>>
>>>> at sun.awt.datatransfer.DataTransferer.setToSortedDataFlavorArray(Unknown Source)
>>>>
>>>> at sun.awt.datatransfer.ClipboardTransferable.<init>(Unknown Source)
>>>>
>>>> at sun.awt.datatransfer.SunClipboard.getContents(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction.actionPerformedImpl(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction.access$700(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction$1.run(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction$1.run(Unknown Source)
>>>>
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>
>>>> at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>>>>
>>>> at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction$2.run(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction$2.run(Unknown Source)
>>>>
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>
>>>> at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>>>>
>>>> at javax.swing.TransferHandler$TransferAction.actionPerformed(Unknown Source)
>>>>
>>>> at javax.swing.text.JTextComponent.invokeAction(Unknown Source)
>>>>
>>>> at javax.swing.text.JTextComponent.paste(Unknown Source)
>>>>
>>>> at javax.swing.text.DefaultEditorKit$PasteAction.actionPerformed(Unknown Source)
>>>>
>>>> at javax.swing.SwingUtilities.notifyAction(Unknown Source)
>>>>
>>>> at javax.swing.JComponent.processKeyBinding(Unknown Source)
>>>>
>>>> at javax.swing.JComponent.processKeyBindings(Unknown Source)
>>>>
>>>> at javax.swing.JComponent.processKeyEvent(Unknown Source)
>>>>
>>>> at java.awt.Component.processEvent(Unknown Source)
>>>>
>>>> at java.awt.Container.processEvent(Unknown Source)
>>>>
>>>> at java.awt.Component.dispatchEventImpl(Unknown Source)
>>>>
>>>> at java.awt.Container.dispatchEventImpl(Unknown Source)
>>>>
>>>> at java.awt.Component.dispatchEvent(Unknown Source)
>>>>
>>>> at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
>>>>
>>>> at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
>>>>
>>>> at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
>>>>
>>>> at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
>>>>
>>>> at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
>>>>
>>>> at java.awt.Component.dispatchEventImpl(Unknown Source)
>>>>
>>>> at java.awt.Container.dispatchEventImpl(Unknown Source)
>>>>
>>>> at java.awt.Window.dispatchEventImpl(Unknown Source)
>>>>
>>>> at java.awt.Component.dispatchEvent(Unknown Source)
>>>>
>>>> at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
>>>>
>>>> at java.awt.EventQueue.access$300(Unknown Source)
>>>>
>>>> at java.awt.EventQueue$3.run(Unknown Source)
>>>>
>>>> at java.awt.EventQueue$3.run(Unknown Source)
>>>>
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>
>>>> at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>>>>
>>>> at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>>>>
>>>> at java.awt.EventQueue$4.run(Unknown Source)
>>>>
>>>> at java.awt.EventQueue$4.run(Unknown Source)
>>>>
>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>
>>>> at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
>>>>
>>>> at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>>>
>>>> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
>>>>
>>>> at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>>>
>>>> at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
>>>>
>>>> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>>>
>>>> at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>>>
>>>> at java.awt.EventDispatchThread.run(Unknown Source)
>>>>
>>>> =============
>>>>
>>>>
>>>>
>>>> When I check the issue tracker http://bugs.java.com/view_bug.do?bug_id=8023043 shows as fixed in 7u60. Did this get fixed in 7u60 through 7u80? The stacktrace is a little different from that bug so should I file this as a new issue?
>>>>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>> Jason
>>>>
>>> 		 	   		




More information about the swing-dev mailing list