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

Bug 253927

Summary: NPE when copying resource linked to non-local filesystem
Product: [Eclipse Project] Platform Reporter: Steve Shelley <steve.shelley>
Component: ResourcesAssignee: Platform-Resources-Inbox <platform-resources-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: steve.shelley
Version: 3.4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Steve Shelley CLA 2008-11-05 10:07:59 EST
Build ID: M20080911-1700

Steps To Reproduce:
1. Install org.eclipse.ui.examples.filesystem
2. create a file resource linked to a memory:/ file
3. from project navigator, try to copy/paste the linked resource to another project.  Results in NPE


More information:
!STACK 0
java.lang.NullPointerException
	at org.eclipse.core.internal.resources.LocationValidator.validateLinkLocation(LocationValidator.java:67)
	at org.eclipse.core.internal.resources.Workspace.validateLinkLocation(Workspace.java:2040)
	at org.eclipse.ui.actions.CopyFilesAndFoldersOperation.validateLinkedResource(CopyFilesAndFoldersOperation.java:1518)
	at org.eclipse.ui.actions.CopyFilesAndFoldersOperation.validateDestination(CopyFilesAndFoldersOperation.java:1374)
	at org.eclipse.ui.actions.CopyFilesAndFoldersOperation.copyResources(CopyFilesAndFoldersOperation.java:545)
	at org.eclipse.ui.actions.CopyFilesAndFoldersOperation.copyResources(CopyFilesAndFoldersOperation.java:497)
	at org.eclipse.ui.internal.navigator.resources.actions.PasteAction.run(PasteAction.java:139)
...

Problem appears to be in CopyFilesAndFoldersOperation.validateLinkedResource(IContainer,IResource) - should probably be using validateLinkLocationURI(), rather than validateLinkLocation(), as the raw location for a non-local filesystem returns a null.
Comment 1 Paul Webster CLA 2008-11-06 09:32:02 EST
I think the NPE in LocationValidator.java:67 should be fixed.

As near as I can tell CopyFilesAndFoldersOperation.java:1518 is using the path to  get an IResource.  Should we get getting a URI from somewhere instead?  If so, where?

PW
Comment 2 John Arthorne CLA 2008-11-06 11:36:44 EST
The fix on the UI side is to use IResource.getRawLocationURI() rather than IResource.getRawLocation(). The only change I can picture making in the core code is to throw an assertion failure rather than an NPE, but the effect will be the same.
Comment 3 John Arthorne CLA 2012-02-06 13:44:50 EST
Bug 370632 was opened for UI side fix. No changes planned in resources.