This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 40785 - Copy/paste doesn't work
Summary: Copy/paste doesn't work
Status: CLOSED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 4.x
Hardware: Sun Solaris
: P2 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: RANDOM
Depends on:
Blocks:
 
Reported: 2004-03-05 09:17 UTC by Jiri Skrivanek
Modified: 2008-12-22 21:45 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Skrivanek 2004-03-05 09:17:22 UTC
It is impossible to do copy/paste in IDE editor
(simply it does nothing). It started to happen in
build 20040304-1515, so I suspect it may be caused
by this integration:

	* core/src/org/netbeans/core/NbClipboard.java:
	 #40693: workaround for JDK bug #4818143 - hang
when accessing
	system clipboard.  Clipboard.setContents(..) also
hangs when
	getContents() hangs.  Both methods must be called
asynchronously

So it can be related to issue 40693. To reproduce:

- run IDE with clean userdir
- open a java file in editor (e.g.
sampledir|examples|colorpicker|ColorPreview)
- select a text
- CTRL+C
- click somewhere else to deselect text
- CTRL+V
- it is normally copied
- now restart IDE (discard changes)
- select a text in editor
- CTRL+C
- click somewhere else to deselect text
- CTRL+V
- nothing happens. If you paste a text to another
application (terminal), it is pasted.

Tested in build 20040304-2247, JDK1.4.2_01, Solaris9.
Comment 1 _ ttran 2004-03-05 10:21:31 UTC
reproducible on Linux too.  It seems yarda's hack is run too late.  At
that time an instance of PasteAction has been already created and
cached by the editor.  We need to install the security manager and the
hack earlier during startup.
Comment 2 Jaroslav Tulach 2004-03-05 12:45:16 UTC
Running my hack late should not be the actual problem.
Comment 3 _ ttran 2004-03-05 14:49:31 UTC
the bug is related to clipboard convertor.  If the calls to convert()
in  NbClipboard are commented out everything works.  The only
convertor we have in NB is org.netbeans.modules.tasklist.core.TaskTransfer

Not clear how this relates to the fix for issue 40693 but without the
fix it works

-> jtulach please
Comment 4 Jaroslav Tulach 2004-03-05 15:44:59 UTC
The problem is caused by following exception, however I am not sure
why is this happening. CCing Mila, he might know more.

sun.io.MalformedInputException: Missing byte-order mark
    at sun.io.ByteToCharUnicode.convert(ByteToCharUnicode.java:120)
    at
sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:247)
    at
sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:297)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at
org.netbeans.editor.LineSeparatorConversion$ToLineFeed.readBuffer(LineSeparatorConversion.java:227)
    at
org.netbeans.editor.LineSeparatorConversion$ToLineFeed.nextConverted(LineSeparatorConversion.java:149)
    at org.netbeans.editor.Analyzer.read(Analyzer.java:499)
    at org.netbeans.editor.BaseDocument.read(BaseDocument.java:935)
    at org.netbeans.editor.BaseKit.read(BaseKit.java:432)
    at
javax.swing.plaf.basic.BasicTextUI$TextTransferHandler.handleReaderImport(BasicTextUI.java:2143)
    at
javax.swing.plaf.basic.BasicTextUI$TextTransferHandler.importData(BasicTextUI.java:2314)
    at
javax.swing.TransferHandler$TransferAction.actionPerformed(TransferHandler.java:820)
    at
javax.swing.text.JTextComponent.invokeAction(JTextComponent.java:1203)
    at javax.swing.text.JTextComponent.paste(JTextComponent.java:1181)
    at
org.netbeans.editor.BaseKit$PasteAction.actionPerformed(BaseKit.java:1297)
    at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:169)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1530)
    at javax.swing.JComponent.processKeyBinding(JComponent.java:2438)
    at javax.swing.JComponent.processKeyBindings(JComponent.java:2473)
    at javax.swing.JComponent.processKeyEvent(JComponent.java:2401)
    at java.awt.Component.processEvent(Component.java:4909)
    at java.awt.Container.processEvent(Container.java:1569)
    at java.awt.Component.dispatchEventImpl(Component.java:3615)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at
java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
    at
java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
    at
java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
    at
java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
    at
java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
    at java.awt.Component.dispatchEventImpl(Component.java:3506)
    at java.awt.Container.dispatchEventImpl(Container.java:1627)
    at java.awt.Window.dispatchEventImpl(Window.java:1606)
    at java.awt.Component.dispatchEvent(Component.java:3477)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
    at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
    at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
    at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Comment 5 _ ttran 2004-03-05 15:56:44 UTC
yarda, how did you produce the exception?  I saw nothing like this
Comment 6 Miloslav Metelka 2004-03-05 16:13:54 UTC
Have no idea what's wrong, just to recap what you likely already know:
1) paste action inspect data flavors and calls
flavor.getReaderForText(transferable) to obtain the Reader which
contains the actual data.

2) EditorKit.read() is called to read the data into the document from
the reader. Editor must be sure that all line-separators get converted
to '\n' i.e. that there will be no extra '\r' so it calls the
LineSeparatorConversion$ToLineFeed which reads the characters from the
given Reader until it hits the exception.
Comment 7 _ ttran 2004-03-05 16:26:27 UTC
> sun.io.MalformedInputException: Missing byte-order mark
>    at sun.io.ByteToCharUnicode.convert(ByteToCharUnicode.java:120)
>    at
sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:247)

just in case, byte-order mark is either "fffe" or "feff" at the very
beginning of the stream, based on that we know it's little- or big-endian
Comment 8 _ ttran 2004-03-05 23:13:31 UTC
I know why Yarda's hack causes this bug.  Before the hack editor
ignored  NbClipboard completely, now it uses NbClipboard.  The
convertor from tasklist is now called when one pastes, before it was
called only when one copied

See also issue 30923
Comment 9 Jaroslav Tulach 2004-03-06 12:38:03 UTC
The issue is caused by presence of a convertor, but the actual bug is
in ExTransferable, it randomly mixes order of the DataTransfers in
itself and that is why sometimes the paste (deep in swing) gets
InputStream, which seems to be a bit buggy instead of String which
works ok.
Comment 10 Jaroslav Tulach 2004-03-06 13:14:32 UTC
Checking in core/bootstrap/src/org/netbeans/TopSecurityManager.java;
/cvs/core/bootstrap/src/org/netbeans/TopSecurityManager.java,v  <-- 
TopSecurityManager.java
new revision: 1.8; previous revision: 1.7
done
Processing log script arguments...
More commits to come...
Checking in core/src/org/netbeans/core/NbClipboard.java;
/cvs/core/src/org/netbeans/core/NbClipboard.java,v  <--  NbClipboard.java
new revision: 1.16; previous revision: 1.15
done
Processing log script arguments...
More commits to come...
RCS file:
/cvs/core/test/unit/src/org/netbeans/core/NbClipboardIsUsedByAlreadyInitializedComponentsTest.java,v
done
Checking in
core/test/unit/src/org/netbeans/core/NbClipboardIsUsedByAlreadyInitializedComponentsTest.java;
/cvs/core/test/unit/src/org/netbeans/core/NbClipboardIsUsedByAlreadyInitializedComponentsTest.java,v
 <--  NbClipboardIsUsedByAlreadyInitializedComponentsTest.java
initial revision: 1.1
done
Checking in
core/test/unit/src/org/netbeans/core/NbClipboardIsUsedBySwingComponentsTest.java;
/cvs/core/test/unit/src/org/netbeans/core/NbClipboardIsUsedBySwingComponentsTest.java,v
 <--  NbClipboardIsUsedBySwingComponentsTest.java
new revision: 1.3; previous revision: 1.2
done
Processing log script arguments...
More commits to come...
Checking in openide/src/org/openide/util/datatransfer/ExTransferable.java;
/cvs/openide/src/org/openide/util/datatransfer/ExTransferable.java,v 
<--  ExTransferable.java
new revision: 1.20; previous revision: 1.19
done
Processing log script arguments...
More commits to come...
RCS file:
/cvs/openide/test/unit/src/org/openide/util/datatransfer/ExTransferableTest.java,v
done
Checking in
openide/test/unit/src/org/openide/util/datatransfer/ExTransferableTest.java;
/cvs/openide/test/unit/src/org/openide/util/datatransfer/ExTransferableTest.java,v
 <--  ExTransferableTest.java
initial revision: 1.1
Comment 11 _ ttran 2004-03-06 20:13:54 UTC
Yarda, can you please prepare a patch on top of the patch for issue
40693 so that we can apply both into release36.  Thanks
Comment 12 Jiri Skrivanek 2004-03-08 14:45:08 UTC
Verified in trunk build 20040308-0913.