Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 141167

Summary: NPE in SimpleObjectTransfer.nativeToJava on Linux
Product: [Tools] GEF Reporter: Chris Lee <eclipse>
Component: GEF-Legacy GEF (MVC)Assignee: Anthony Hunter <ahunter.eclipse>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bugs.eclipse.org, nyssen, rudolf.hornig, veronika_irvine
Version: 3.2   
Target Milestone: 3.4.1 (Ganymede SR1)   
Hardware: PC   
OS: Linux-GTK   
Whiteboard:
Attachments:
Description Flags
patch for the NPE - checks for null before using nyssen: iplog+

Description Chris Lee CLA 2006-05-10 17:47:45 EDT
When trying to use the default GEF clipboard (org.eclipse.gef.ui.actions.Clipboard), the transfer object (SimpleObjectTransfer) doesn't properly handle null as a return value from org.eclipse.swt.dnd.ByteArrayTransfer.nativeToJava.

On both Windows and Linux, this method may return null, though on Linux it happens also if there is no data, while on Windows, an empty byte array is returned instead.

SimpleObjectTransfer should handle null return values from super.nativeToJava before trying to construct a String from it, otherwise an NPE happens.
Comment 1 Chris Lee CLA 2006-05-10 17:51:27 EDT
Created attachment 41058 [details]
patch for the NPE - checks for null before using

I've attached a simple patch for doing the req'd null check.
Comment 2 Randy Hudson CLA 2006-05-10 18:45:58 EDT
Veronika, could you comment on the consistency of ByteArrayTransfer here?
Comment 3 Randy Hudson CLA 2006-05-10 18:50:44 EDT
Chris, when does this happen? Is it when the clipboard contains some other transfer type? Please provide steps to reproduce. I don't understand how a transfer gets invoked unless it's working with bytes that it knows how to read.
Comment 4 Chris Lee CLA 2006-05-11 20:03:38 EDT
It happens when the clipboard is empty and we try to get data from the clipboard.  The specific problem only happens on Linux, where ByteArrayTransfer returns null if there is no data, compared to Windows where it returns an empty byte array.
Comment 5 Ludovic Gasc (Comeetings) CLA 2007-09-25 06:29:15 EDT
I have this problem sometimes with Eclipse 3.3 on Linux when I copy-paste.

Somebody could apply this patch on the trunk ?

Thanks you very much.
Comment 6 Rudolf Hornig CLA 2008-05-14 10:41:47 EDT
(In reply to comment #5)
> I have this problem sometimes with Eclipse 3.3 on Linux when I copy-paste.
> 
> Somebody could apply this patch on the trunk ?
> 
> Thanks you very much.

This happens also when for example some text is copied from Skype to the clipboard. All GEF application that has PasteAction crashes with NPE because of this problem.

Comment 7 Anthony Hunter CLA 2008-07-11 17:03:13 EDT
Committed the requested fix to HEAD and R3_4_maintenance