JDK-7107490 : "java.io.IOException: Owner failed to convert data" when pasting large data
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2011-11-02
  • Updated: 2013-12-13
  • Resolved: 2013-12-13
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 8
8Resolved
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
$ java -version
java version "1.7.0"
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Server VM (build 21.0-b17, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
$ uname -a
Linux  3.0.0-12-generic-pae #20-Ubuntu SMP Fri Oct 7 16:37:17 UTC 2011 i686 i686 i386 GNU/Linux


A DESCRIPTION OF THE PROBLEM :
getReaderForText(transferable); code fails when the amount of data on the clipboard is large (> ~256kB):

java.io.IOException: Owner failed to convert data



The error seems evident in XSelection.java where dataGetter.dispose() is called before  validateDataGetter(dataGetter); in the method  getData(long format, long time):

This happens only for incremental transfer which should explain the size dependency. This bug relates to several reported bugs with this issue that has been disregarded due to "Not reproducible" like Bug ID: 6936006.

The error seems obvious...



REGRESSION.  Last worked in version 6u29

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the code below when there is a large amount of text on the clipboard (> 56 k)Code below fails when the amount of data on the clipboard is large (> ~256kB):



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Printout of text on clipboard

ACTUAL -
java.io.IOException: Owner failed to convert data

ERROR MESSAGES/STACK TRACES THAT OCCUR :

java.io.IOException: Owner failed to convert data
	at sun.awt.X11.XSelection.validateDataGetter(XSelection.java:444)
	at sun.awt.X11.XSelection.getData(XSelection.java:378)
	at sun.awt.X11.XClipboard.getClipboardData(XClipboard.java:120)
	at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(ClipboardTransferable.java:118)
	at sun.awt.datatransfer.ClipboardTransferable.<init>(ClipboardTransferable.java:97)
	at sun.awt.X11.XClipboard.getContents(XClipboard.java:106)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.io.LineNumberReader;
import java.io.Reader;


public class PasteTest {
	static private void paste() {
		Transferable transferable = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
		DataFlavor [] availableFlavors = transferable.getTransferDataFlavors();
		DataFlavor selectedFlavor = DataFlavor.selectBestTextFlavor(availableFlavors);
		try {
			Reader reader = selectedFlavor.getReaderForText(transferable);

			LineNumberReader lnr = new LineNumberReader(reader);
			String line = lnr.readLine();
			while (line != null) {
				System.err.println(line);
				line = lnr.readLine();
			}
		} catch (Exception e) {
			e.printStackTrace();
			return;
		}
	}
	
	public static void main(String [] args) {
		paste();
	}
}

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

CUSTOMER SUBMITTED WORKAROUND :
Workaround: Use java-6

  Fix: fix code in XSelection.java where, for incremental  dataGetter.dispose() is called before  validateDataGetter(dataGetter); in the method  getData(long format, long time):

                   dataGetter.dispose();

                    ByteArrayOutputStream dataStream = new ByteArrayOutputStream(len);

                    while (true) {
                        WindowPropertyGetter incrDataGetter =
                            new WindowPropertyGetter(XWindow.getXAWTRootWindow().getWindow(),
                                                     selectionPropertyAtom,
                                                     0, MAX_LENGTH, false,
                                                     XConstants.AnyPropertyType);

                        try {
                            XToolkit.awtLock();
                            XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
                                                        incrementalTransferHandler);

                            propertyGetter = incrDataGetter;

                            try {
                                XlibWrapper.XDeleteProperty(XToolkit.getDisplay(),
                                                            XWindow.getXAWTRootWindow().getWindow(),
                                                            selectionPropertyAtom.getAtom());

                                // If the owner doesn't respond within the
                                // SELECTION_TIMEOUT, we terminate incremental
                                // transfer.
                                waitForSelectionNotify(incrDataGetter);
                            } catch (InterruptedException ie) {
                                break;
                            } finally {
                                propertyGetter = null;
                                XToolkit.removeEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
                                                               incrementalTransferHandler);
                                XToolkit.awtUnlock();
                            }

                            validateDataGetter(dataGetter);

Comments
JDK-7191086
06-03-2013

Looks like a duplicate of JDK-7199196.
05-02-2013

Raising priority to P3. Affecting NetBeans IDE users.
14-11-2012