Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342060 - Renaming a project failing with custom EFS
Summary: Renaming a project failing with custom EFS
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.6.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.8 M5   Edit
Assignee: Serge Beauchamp CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-06 14:12 EDT by Robert Konigsberg CLA
Modified: 2012-01-30 05:24 EST (History)
6 users (show)

See Also:


Attachments
Patch (960 bytes, patch)
2011-04-07 06:49 EDT, Serge Beauchamp CLA
no flags Details | Diff
Fix for the bug (983 bytes, patch)
2011-04-07 10:26 EDT, Serge Beauchamp CLA
no flags Details | Diff
Regression tests (9.86 KB, patch)
2012-01-25 07:56 EST, Serge Beauchamp CLA
no flags Details | Diff
Fix junit test on Linux (1.48 KB, patch)
2012-01-30 05:24 EST, Serge Beauchamp CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Konigsberg CLA 2011-04-06 14:12:21 EDT
Build Identifier: M20100909-0800

Renaming an Eclipse project is failing; here's the tail of the stack trace:


java.lang.NullPointerException
at org.eclipse.core.internal.resources.Workspace.transferVariableDefinition(Workspace.java:824)
at org.eclipse.core.internal.resources.Workspace.copyTree(Workspace.java:761)
at org.eclipse.core.internal.resources.Workspace.copyTree(Workspace.java:815)
at org.eclipse.core.internal.resources.Workspace.move(Workspace.java:1753)
at org.eclipse.core.internal.resources.ResourceTree.movedProjectSubtree(ResourceTree.java:669)

I think the problem is with the last line, which looks like this:

IPath srcLoc = source.getLocation();
IPath srcRawLoc = source.getRawLocation();
++ if ((srcLoc != null) && !srcRawLoc.equals(srcLoc)) {

Should that be 

++ if ((srcRawLoc != null) && !srcRawLoc.equals(srcLoc)) {

?


Reproducible: Always
Comment 1 Serge Beauchamp CLA 2011-04-07 06:48:38 EDT
In your case, 'srcLoc' isn't null, but 'srcRawLoc' is null?  How can this be?  

Normally, the possible case is the opposite - srcRawLoc isn't null, but srcLoc can be null.

Is this something you directly control in your EFS plugin?
Comment 2 Serge Beauchamp CLA 2011-04-07 06:49:02 EDT
Created attachment 192720 [details]
Patch

Patch
Comment 3 Robert Konigsberg CLA 2011-04-07 10:23:28 EDT
Yes, that is correct. The resource has a uri other than file:.

I just updated this bug to indicate that it was found in 3.6.1 - can you please see if it can get in to the 3.7 stream? Or perhaps you already have.
Comment 4 Serge Beauchamp CLA 2011-04-07 10:26:17 EDT
Created attachment 192750 [details]
Fix for the bug
Comment 5 Serge Beauchamp CLA 2011-04-07 10:27:48 EDT
(In reply to comment #3)
> Yes, that is correct. The resource has a uri other than file:.
> 

Fair enough, but then, how come IResource.getLocation() doesn't return null as well?

I'm sure there's a lot of code that make the assumption that if (IResource.getLocation() != null), then (IResource.getRawLocation != null) as well.
Comment 6 Serge Beauchamp CLA 2011-04-07 10:28:18 EDT
Szymon, can you review it please?  Is it too late to get it in 3.7?
Comment 7 Robert Konigsberg CLA 2011-04-07 11:41:48 EDT
Oh this must be important - we got John on the case. Hi John! (No offense to the others. :))
Comment 8 John Arthorne CLA 2011-04-07 13:57:17 EDT
(In reply to comment #7)
> Oh this must be important - we got John on the case. Hi John! (No offense to
> the others. :))

I am mainly curious to hear the answer to Serge's question. In what situation is the raw location null, but getLocation is not null? This implies you have a linked resource that exists, but has undefined location.
Comment 9 Robert Konigsberg CLA 2011-04-07 14:18:47 EDT
John,

Gah, I wrote up an explanation. How is it not here!

source.getRawLocation calls


public IPath getRawLocation() {
  if (isLinked())
    return FileUtil.toPath(((Project) getProject()).internalGetDescription().getLinkLocationURI(getProjectRelativePath()));
  return getLocation();
}

FileUtil.toPath says:


public static IPath toPath(URI uri) {
  if (uri == null)
    return null;
  final String scheme = uri.getScheme();
  // null scheme represents path variable
  if (scheme == null || EFS.SCHEME_FILE.equals(scheme))
    return new Path(uri.getSchemeSpecificPart());
  return null;
}

Since the scheme of our custom filesystem is not null and not "file", this returns null.
Comment 10 John Arthorne CLA 2011-04-07 14:32:11 EDT
(In reply to comment #9)

That answers half the question. I suppose the other half is that your EFS implementation is returning non-null for IFileStore#toLocalFile. So the real bug seems to be that getLocation and getRawLocation are using inconsistent methods to convert from URI to IPath.  getRawLocation uses FileUtil#toPath, but getLocation uses FileStoreRoot#toLocalPath, which consults the EFS to see if the IFileStore can be mapped to a local file. In this case I think the fix is for getRawLocation to also use FileStoreRoot#toLocalPath so they are consistent here.
Comment 11 Robert Konigsberg CLA 2011-04-07 14:34:11 EDT
I am going to talk with Terry about whether our filesystem should return a value for IFileStore#toLocalFile. Thanks!
Comment 12 Serge Beauchamp CLA 2011-12-01 11:08:07 EST
setting target to 3.8M5
Comment 13 Serge Beauchamp CLA 2012-01-19 14:21:02 EST
Now fixed on git repository, under the master branch.
Comment 14 Szymon Brandys CLA 2012-01-24 05:34:46 EST
(In reply to comment #13)
> Now fixed on git repository, under the master branch.

Hi Serge, could you also attach a regression test?
Comment 15 Serge Beauchamp CLA 2012-01-24 06:43:59 EST
Ok, I'll get back to you about it.
Comment 16 Serge Beauchamp CLA 2012-01-25 07:56:55 EST
Created attachment 210045 [details]
Regression tests

regression test
Comment 17 John Arthorne CLA 2012-01-29 20:12:05 EST
This new test is failing on both Linux and Mac. 

junit.framework.AssertionFailedError: 1.0: org.eclipse.core.internal.resources.ResourceException: Problems encountered while moving resources.
at org.eclipse.core.tests.harness.CoreTest.fail(CoreTest.java:67)
at org.eclipse.core.tests.resources.NonLocalLinkedResourceTest.test342060(NonLocalLinkedResourceTest.java:258)

See:

http://download.eclipse.org/eclipse/downloads/drops/N20120128-2000/testresults/html/org.eclipse.core.tests.resources_linux.gtk.x86_6.0.html
Comment 18 Serge Beauchamp CLA 2012-01-30 05:24:16 EST
Created attachment 210254 [details]
Fix junit test on Linux
Comment 19 Serge Beauchamp CLA 2012-01-30 05:24:49 EST
JUnit test now pass on Linux.  I'll verify it works on MacOS X as well shortly.