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

Bug 339859

Summary: Infinite loop when copying files between projects using linked resources
Product: [Eclipse Project] Platform Reporter: Serge Beauchamp <serge>
Component: ResourcesAssignee: Serge Beauchamp <serge>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: yevshif
Version: 3.6.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
fix
none
regression none

Description Serge Beauchamp CLA 2011-03-14 06:10:25 EDT
When copying files using linked resources and path variables between project, it can sometimes cause an infinite loop in:


This patch turned out to cause an infinite loop with the following stack trace:


Thread [main] (Suspended)    
    ProjectPathVariableManager.isDefined(String) line: 168    
    PathVariableUtil.getUniqueVariableName(String, IResource) line: 36    
    Workspace.copyVariable(IResource, IResource, String) line: 885    
    Workspace.transferVariableDefinition(IResource, IResource, URI) line: 828   
    Workspace.copyTree(IResource, IPath, int, int, boolean, boolean, boolean)
line: 761    
    Workspace.move(Resource, IPath, int, int, boolean) line: 1753    
    ResourceTree.movedFile(IFile, IFile) line: 537    
    ResourceTree.standardMoveFile(IFile, IFile, int, IProgressMonitor) line:
917    
    File(Resource).unprotectedMove(ResourceTree, IResource, int,
IProgressMonitor) line: 1967    
    File(Resource).move(IPath, int, IProgressMonitor) line: 1597    
    LinkedResourceWithPathVariableTest.testMoveFileToDifferentProject() line:
428    
    NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]    
    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39    
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25    
    Method.invoke(Object, Object...) line: 597    
    LinkedResourceWithPathVariableTest(TestCase).runTest() line: 168    
    LinkedResourceWithPathVariableTest(TestCase).runBare() line: 134    
    TestResult$1.protect() line: 110    
    TestResult.runProtected(Test, Protectable) line: 128    
    TestResult.run(TestCase) line: 113    
    LinkedResourceWithPathVariableTest(TestCase).run(TestResult) line: 124    
    TestSuite.runTest(Test, TestResult) line: 232    
    TestSuite.run(TestResult) line: 227    
    JUnit3TestReference.run(TestExecution) line: 130    
    TestExecution.run(ITestReference[]) line: 38    
    RemotePluginTestRunner(RemoteTestRunner).runTests(String[], String,
TestExecution) line: 467    
    RemotePluginTestRunner(RemoteTestRunner).runTests(TestExecution) line: 683  
    RemotePluginTestRunner(RemoteTestRunner).run() line: 390    
    RemotePluginTestRunner.main(String[]) line: 62    
    UITestApplication$1.run() line: 116    
    RunnableLock.run() line: 35    
    UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 134    
    Display.runAsyncMessages(boolean) line: 4041    
    Display.readAndDispatch() line: 3660    
    Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2640    
    Workbench.runUI() line: 2604    
    Workbench.access$4(Workbench) line: 2438    
    Workbench$7.run() line: 671    
    Realm.runWithDefault(Realm, Runnable) line: 332    
    Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 664    
    PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149    
    IDEApplication.start(IApplicationContext) line: 115    
    UITestApplication.start(IApplicationContext) line: 47    
    EclipseAppHandle.run(Object) line: 196    
    EclipseAppLauncher.runApplication(Object) line: 110    
    EclipseAppLauncher.start(Object) line: 79    
    EclipseStarter.run(Object) line: 369    
    EclipseStarter.run(String[], Runnable) line: 179    
    NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]    
    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39    
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25    
    Method.invoke(Object, Object...) line: 597    
    Main.invokeFramework(String[], URL[]) line: 619    
    Main.basicRun(String[]) line: 574    
    Main.run(String[]) line: 1407    
    Main.main(String[]) line: 1383



This is because when copying resources, their variables will be copied too, and
if one exists already in the destination project but with a different value,
the code will try to find a new unique variable by appending an incremented
suffix (VAR1, VAR2, etc...).

This is true only when the variable VAR is provided by the variable
resolvers extension mechanism, not entered by the user, and is a variable that takes an argument ("VAR-ARG").

    public boolean isDefined(String varName) {
        for (int i = 0; i < variableProviders.length; i++) {
            if (varName.startsWith(variableProviders[i].getName()))
                return true;

In the later case, when "VAR" already exist in the destination project, and we
try to copy a linked resource starting with "VAR", the PVM will return that
VAR, VAR1, VAR2, VAR3, etc... are all defined, hence the infinite loop.
Comment 1 Serge Beauchamp CLA 2011-03-14 06:11:12 EDT
Created attachment 191094 [details]
fix
Comment 2 Serge Beauchamp CLA 2011-03-14 06:11:39 EDT
assigned
Comment 3 Serge Beauchamp CLA 2011-03-14 06:12:07 EDT
Copied from 

Bug 305036 - [Path Variables] Minor API changes in Dynamic Path Variables area
Comment 4 Serge Beauchamp CLA 2011-03-14 06:12:55 EDT
Created attachment 191095 [details]
regression
Comment 5 Lars Vogel CLA 2019-11-14 02:19:40 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.