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

Bug 543776

Summary: build order may be wrong if project name in workspace doesn't match project name in .project file
Product: [Eclipse Project] Platform Reporter: Reto Weiss <reto.weiss>
Component: ResourcesAssignee: Reto Weiss <reto.weiss>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: christian.dietrich.opensource, loskutov, stephan.herrmann
Version: 4.7   
Target Milestone: 4.11 M3   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/135689
https://bugs.eclipse.org/bugs/show_bug.cgi?id=536592
https://bugs.eclipse.org/bugs/show_bug.cgi?id=507795
https://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=daf7fb70f33aa29ef831772534496a18291165d6
https://git.eclipse.org/r/135807
https://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=682eeb2d2dff0189910750b64b3956c25da92ddb
https://git.eclipse.org/r/135901
https://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/?id=b8a5b1b3c0a50efb5d7e3e8e14183b530c99105f
Whiteboard:
Attachments:
Description Flags
Unzip this to your workspace directory and import the unzipped projects none

Description Reto Weiss CLA 2019-01-24 05:05:48 EST
The build order (Workspace.getBuildOrder) may be wrong if a project's name in the workspace does not match the project's name in the .project file.

The following exception will be thrown and silently ignored in the method getAllBuildConfigReferences of class ProjectDescription:

org.eclipse.core.internal.resources.ResourceException(/Test)[368]: java.lang.Exception: Resource '/Test' does not exist.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:39)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:35)
	at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:327)
	at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:201)
	at org.eclipse.core.internal.resources.Project.checkAccessible(Project.java:142)
	at org.eclipse.core.internal.resources.Project.getBuildConfig(Project.java:357)
	at org.eclipse.core.internal.resources.ProjectDescription.getAllBuildConfigReferences(ProjectDescription.java:264)
	at org.eclipse.core.internal.resources.Project.internalGetReferencedBuildConfigs(Project.java:792)
	at org.eclipse.core.internal.resources.Workspace.computeActiveBuildConfigGraph(Workspace.java:752)
	at org.eclipse.core.internal.resources.Workspace.getBuildGraph(Workspace.java:1617)
	at org.eclipse.core.internal.resources.Workspace.getBuildOrder(Workspace.java:1598)
	at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:142)
	at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:232)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

A project's name in the workspace can be different from the project's name in the .project file. You can reproduce this by:
1. Create new Project 'Test' in the default workspace location.
2. Delete the Project in the workspace but not on disk.
3. Rename the Project's folder on the disk to 'TestRenamedFolder'.
4. Import the Project again with the 'Existing Projects into Workspace' Import Wizard.
5. The project will now be imported with the project's name 'TestRenamedFolder'. The project's name in the .project file is still 'Test'.

See also attached zip file with two test projects. You can unzip the file to the workspace directory and import both projects into the workspace. A clean will trigger the exception above. The extension point org.eclipse.core.resources.IDynamicReferenceProvider will not be called for the 'TestRenamedFolder' project and therefore the dependency to the project 'Base' will not be considered.
Comment 1 Reto Weiss CLA 2019-01-24 05:14:17 EST
Created attachment 277264 [details]
Unzip this to your workspace directory and import the unzipped projects
Comment 2 Eclipse Genie CLA 2019-01-24 05:43:18 EST
New Gerrit change created: https://git.eclipse.org/r/135689
Comment 3 Andrey Loskutov CLA 2019-01-24 14:32:19 EST
I believe the code is old, from 3.x times, so this is not a regression in 4.8?
Comment 4 Reto Weiss CLA 2019-01-24 16:33:07 EST
Hi Andrey

No it is not a regression. I asume this bug is there since a long time. 4.8 is the version we currently use for our product.

Regards
Comment 5 Andrey Loskutov CLA 2019-01-25 17:00:20 EST
It looks like the problem is coming from bug 507795 commit 6fc45bc9c9ccf8c3d1db3213bb423d6e912182df.
Comment 7 Andrey Loskutov CLA 2019-01-26 02:54:36 EST
(In reply to Eclipse Genie from comment #6)
> Gerrit change https://git.eclipse.org/r/135689 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/
> ?id=daf7fb70f33aa29ef831772534496a18291165d6 

This causes 28 test fails in 
jdt.ui.tests.refactoring tests in the https://download.eclipse.org/eclipse/downloads/drops4/I20190125-1800/testResults.php build.

I'm looking into this.
Comment 8 Andrey Loskutov CLA 2019-01-26 06:23:12 EST
So far it looks like the test issue only. For example org.eclipse.jdt.ui.tests.refactoring.RenameJavaProjectTests.test0 fails to rename project which is referenced by other projects, because it looks like that the .classpath references still point to the old project name. Doing the same in real Eclipse shows no issues, .classpath references of dependent projects are updated properly.
Comment 9 Stephan Herrmann CLA 2019-01-26 07:57:26 EST
(In reply to Andrey Loskutov from comment #7)
> (In reply to Eclipse Genie from comment #6)
> > Gerrit change https://git.eclipse.org/r/135689 was merged to [master].
> > Commit:
> > http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/
> > ?id=daf7fb70f33aa29ef831772534496a18291165d6 
> 
> This causes 28 test fails in 
> jdt.ui.tests.refactoring tests in the
> https://download.eclipse.org/eclipse/downloads/drops4/I20190125-1800/
> testResults.php build.
> 
> I'm looking into this.

Also in the same bucket:
org.eclipse.jdt.core.tests.model.JavaSearchMultipleProjectsTests.testHierarchyScope3()

Started to fail on I20190125-1800, which can be reproduced also locally.
Comment 10 Stephan Herrmann CLA 2019-01-26 12:56:26 EST
(In reply to Stephan Herrmann from comment #9)
> (In reply to Andrey Loskutov from comment #7)
> > (In reply to Eclipse Genie from comment #6)
> > > Gerrit change https://git.eclipse.org/r/135689 was merged to [master].
> > > Commit:
> > > http://git.eclipse.org/c/platform/eclipse.platform.resources.git/commit/
> > > ?id=daf7fb70f33aa29ef831772534496a18291165d6 
> > 
> > This causes 28 test fails in 
> > jdt.ui.tests.refactoring tests in the
> > https://download.eclipse.org/eclipse/downloads/drops4/I20190125-1800/
> > testResults.php build.
> > 
> > I'm looking into this.
> 
> Also in the same bucket:
> org.eclipse.jdt.core.tests.model.JavaSearchMultipleProjectsTests.
> testHierarchyScope3()
> 
> Started to fail on I20190125-1800, which can be reproduced also locally.

Also here: https://ci.eclipse.org/jdt/job/eclipse.jdt.core-Gerrit/1612/testReport/org.eclipse.jdt.core.tests.model/JavaSearchMultipleProjectsTests/testHierarchyScope3/
Comment 11 Eclipse Genie CLA 2019-01-26 13:31:05 EST
New Gerrit change created: https://git.eclipse.org/r/135807
Comment 12 Andrey Loskutov CLA 2019-01-26 13:37:21 EST
(In reply to Stephan Herrmann from comment #9)
> Also in the same bucket:
> org.eclipse.jdt.core.tests.model.JavaSearchMultipleProjectsTests.
> testHierarchyScope3()
> 
> Started to fail on I20190125-1800, which can be reproduced also locally.

(In reply to Stephan Herrmann from comment #10)
> Also here:
> https://ci.eclipse.org/jdt/job/eclipse.jdt.core-Gerrit/1612/testReport/org.
> eclipse.jdt.core.tests.model/JavaSearchMultipleProjectsTests/
> testHierarchyScope3/

Sorry for that. We should not let Gerrits to fail for other projects (JDT & JDT UI). 

(In reply to Eclipse Genie from comment #11)
> New Gerrit change created: https://git.eclipse.org/r/135807

I plan to revert the change partly, because we can't revert it fully to avoid decremented bundle version and because I haven't found yet the root cause for test failures and cannot guarantee I will have time to do this soon.

@Reto: if you would have time to investigate test failures, it would be great.
Comment 14 Reto Weiss CLA 2019-01-28 11:47:31 EST
Hi Andrey

Tests are correct. There is a bug in my implementation of IProject.getReferencingProject(). Will fix this and also add a test for this method.

How to proceed? Should I open a new gerrit or change the old one?

Regards

Reto
Comment 15 Andrey Loskutov CLA 2019-01-28 12:01:07 EST
Please create new gerrit. Thanks Reto.
Comment 16 Eclipse Genie CLA 2019-01-28 16:13:22 EST
New Gerrit change created: https://git.eclipse.org/r/135901
Comment 18 Andrey Loskutov CLA 2019-02-07 04:03:58 EST
Thanks Reto! No regressions in https://download.eclipse.org/eclipse/downloads/drops4/I20190206-1800/testResults.php.

If you have some time, you could also check bug 543920 and bug 543919 which is on my wish list for fixing soon.
Comment 19 Reto Weiss CLA 2019-02-07 05:03:11 EST
Hi Andrey

Thanks for your help. 

I could imagine that bug 543920 and bug 543919 are caused by this bug here.

JDT Builder checks if all referenced projects are build before building a project. If a referenced project is not build (e.g. because of a wrong build order) it creates a marker with the text mentioned in those bugs. Then it stops the building of the project. After the referenced projects are build the referencing projects will be build again and the marker is removed.

Example:
Project B depends on Project A

1. Project B is build. JDT Builder checks if Project A is already build. Since it is not yet build it creates the marker. It returns Project A as dependency to the build system and do not build Project B.
2. Project A is build.
3. Project B is build because it depends on Project A. JDT Builder removes the marker and builds Project B.

Regards
Reto