Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 97949 Details for
Bug 137398
[Preferences] WorkingCopyPreferences attempts to set value of removed node
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Martin's patch with fixed tests
137398_20080429.txt (text/plain), 10.84 KB, created by
Szymon Brandys
on 2008-04-29 07:35:09 EDT
(
hide
)
Description:
Martin's patch with fixed tests
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2008-04-29 07:35:09 EDT
Size:
10.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.resources >Index: src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java,v >retrieving revision 1.25 >diff -u -r1.25 ProjectPreferencesTest.java >--- src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java 1 Feb 2008 17:39:13 -0000 1.25 >+++ src/org/eclipse/core/tests/internal/resources/ProjectPreferencesTest.java 29 Apr 2008 11:32:58 -0000 >@@ -288,8 +288,8 @@ > } > > try { >- // project pref should not exist >- assertTrue("3.0", !parent.nodeExists(project.getName())); >+ // project pref should be cleared (see bug 137398) >+ assertTrue("3.0", isNodeCleared(parent, new String[]{project.getName()})); > } catch (BackingStoreException e) { > fail("3.1", e); > } >@@ -324,11 +324,11 @@ > fail("2.0", e); > } > >- // ensure that preferences for the old project are removed >+ // ensure that preferences for the old project are cleared (see bug 137398) > node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE); > assertNotNull("2.1", node); > try { >- assertTrue("2.2", !node.nodeExists(project1.getName())); >+ assertTrue("2.2", isNodeCleared(node, new String[] {project1.getName()})); > } catch (BackingStoreException e) { > fail("2.3", e); > } >@@ -352,6 +352,25 @@ > assertNotNull("4.1", node); > assertEquals("4.2", value, node.get(key, null)); > } >+ >+ /** >+ * @param node the node to check >+ * @param childrenNames the names of children to check >+ * @return true, if the node and its children have no associated values >+ * @throws BackingStoreException >+ */ >+ private boolean isNodeCleared(Preferences node, String[] childrenNames) throws BackingStoreException { >+ // check if the node has associate values >+ if (node.keys().length !=0) return false; >+ >+ // perform a subsequent check for the node children >+ Preferences childNode = null; >+ for (int i=0; i<childrenNames.length; i++){ >+ childNode = node.node(childrenNames[i]); >+ if (!isNodeCleared(childNode, childNode.childrenNames())) return false; >+ } >+ return true; >+ } > > /** > * Regression test for Bug 60925 - project preferences do not show up in workspace. >@@ -894,7 +913,7 @@ > assertTrue("3.1", !fileInFS.exists()); > IEclipsePreferences projectNode = (IEclipsePreferences) service.getRootNode().node(ProjectScope.SCOPE).node(project.getName()); > try { >- assertTrue("3.2", !projectNode.nodeExists(qualifier)); >+ assertTrue("3.2", isNodeCleared(projectNode, new String[]{qualifier})); > } catch (BackingStoreException e) { > fail("3.91", e); > } >Index: src/org/eclipse/core/tests/resources/CharsetTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/CharsetTest.java,v >retrieving revision 1.29 >diff -u -r1.29 CharsetTest.java >--- src/org/eclipse/core/tests/resources/CharsetTest.java 16 Nov 2007 16:49:06 -0000 1.29 >+++ src/org/eclipse/core/tests/resources/CharsetTest.java 29 Apr 2008 11:32:58 -0000 >@@ -951,7 +951,8 @@ > */ > public void testMovingProject() throws CoreException { > IWorkspace workspace = getWorkspace(); >- IProject project1 = workspace.getRoot().getProject("Project1"); >+ String project1Name = getUniqueString(); >+ IProject project1 = workspace.getRoot().getProject(project1Name); > IProject project2 = null; > try { > IFolder folder = project1.getFolder("folder1"); >@@ -967,8 +968,10 @@ > assertEquals("1.3", "FOO", project1.getDefaultCharset()); > > // move project and ensures charsets settings are preserved >- project1.move(new Path("Project2"), false, null); >- project2 = workspace.getRoot().getProject("Project2"); >+ String project2Name = getUniqueString(); >+ project1.move(new Path(project2Name), false, null); >+ >+ project2 = workspace.getRoot().getProject(project2Name); > folder = project2.getFolder("folder1"); > file1 = project2.getFile("file1.txt"); > file2 = folder.getFile("file2.txt"); >#P org.eclipse.core.resources >Index: src/org/eclipse/core/internal/resources/Resource.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java,v >retrieving revision 1.160 >diff -u -r1.160 Resource.java >--- src/org/eclipse/core/internal/resources/Resource.java 26 Mar 2008 14:55:50 -0000 1.160 >+++ src/org/eclipse/core/internal/resources/Resource.java 29 Apr 2008 11:33:00 -0000 >@@ -766,15 +766,15 @@ > for (Iterator it = links.iterator(); it.hasNext();) > workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_DELETE, (IResource) it.next())); > >- // check if we deleted a preferences file >- ProjectPreferences.deleted(this); >- > /* if we are synchronizing, do not delete the resource. Convert it > into a phantom. Actual deletion will happen when we refresh or push. */ > if (convertToPhantom && getType() != PROJECT && synchronizing(getResourceInfo(true, false))) > convertToPhantom(); > else > workspace.deleteResource(this); >+ >+ // check if we deleted a preferences file >+ ProjectPreferences.deleted(this); > > //remove all deleted linked resources from the project description > if (getType() != IResource.PROJECT && links != null) { >Index: src/org/eclipse/core/internal/resources/ProjectPreferences.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectPreferences.java,v >retrieving revision 1.53 >diff -u -r1.53 ProjectPreferences.java >--- src/org/eclipse/core/internal/resources/ProjectPreferences.java 27 Mar 2007 22:27:37 -0000 1.53 >+++ src/org/eclipse/core/internal/resources/ProjectPreferences.java 29 Apr 2008 11:33:00 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -107,14 +107,8 @@ > // ignore > } > >- // if the node was loaded we need to clear the values and remove >- // its reference from the parent (don't save it though) >- // otherwise just remove the reference from the parent >- String childPath = projectNode.absolutePath() + IPath.SEPARATOR + qualifier; >- if (projectNode.isAlreadyLoaded(childPath)) >- removeNode(projectNode.node(qualifier)); >- else >- projectNode.removeNode(qualifier); >+ // clear the preferences >+ nodeDeleted(projectNode.node(qualifier)); > > // notifies the CharsetManager if needed > if (qualifier.equals(ResourcesPlugin.PI_RESOURCES)) >@@ -136,8 +130,8 @@ > Preferences projectNode = root.node(ProjectScope.SCOPE).node(project); > // check if we need to notify the charset manager > boolean hasResourcesSettings = getFile(folder, ResourcesPlugin.PI_RESOURCES).exists(); >- // remove the preferences >- removeNode(projectNode); >+ // clear the preferences >+ nodeDeleted(projectNode); > // notifies the CharsetManager > if (hasResourcesSettings) > preferencesChanged(folder.getProject()); >@@ -155,8 +149,8 @@ > Preferences projectNode = root.node(ProjectScope.SCOPE).node(project.getName()); > // check if we need to notify the charset manager > boolean hasResourcesSettings = getFile(project, ResourcesPlugin.PI_RESOURCES).exists(); >- // remove the preferences >- removeNode(projectNode); >+ // clear the preferences >+ nodeDeleted(projectNode); > // notifies the CharsetManager > if (hasResourcesSettings) > preferencesChanged(project); >@@ -241,12 +235,22 @@ > node.isReading = oldIsReading; > } > } >+ >+ private static void clearAll(Preferences node) throws BackingStoreException { >+ node.clear(); >+ String[] names = node.childrenNames(); >+ for (int i = 0; i < names.length; i++) { >+ clearAll(node.node(names[i])); >+ } >+ } > >- static void removeNode(Preferences node) throws CoreException { >- String message = NLS.bind(Messages.preferences_removeNodeException, node.absolutePath()); >+ static void nodeDeleted(Preferences node) throws CoreException { >+ // if the underlying properties file was deleted, clear the values and remove >+ // it from the list of loaded classes keep the node as it might still be referenced > try { >- node.removeNode(); >+ clearAll(node); > } catch (BackingStoreException e) { >+ String message = NLS.bind(Messages.preferences_clearNodeException, node.absolutePath()); > IStatus status = new Status(IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IStatus.ERROR, message, e); > throw new CoreException(status); > } >Index: src/org/eclipse/core/internal/utils/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Messages.java,v >retrieving revision 1.33 >diff -u -r1.33 Messages.java >--- src/org/eclipse/core/internal/utils/Messages.java 29 Jun 2006 18:32:57 -0000 1.33 >+++ src/org/eclipse/core/internal/utils/Messages.java 29 Apr 2008 11:33:00 -0000 >@@ -105,7 +105,7 @@ > public static String preferences_deleteException; > public static String preferences_loadException; > public static String preferences_operationCanceled; >- public static String preferences_removeNodeException; >+ public static String preferences_clearNodeException; > public static String preferences_saveProblems; > public static String preferences_syncException; > >Index: src/org/eclipse/core/internal/utils/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/messages.properties,v >retrieving revision 1.126 >diff -u -r1.126 messages.properties >--- src/org/eclipse/core/internal/utils/messages.properties 21 Aug 2006 14:05:22 -0000 1.126 >+++ src/org/eclipse/core/internal/utils/messages.properties 29 Apr 2008 11:33:00 -0000 >@@ -101,7 +101,7 @@ > preferences_deleteException=Exception deleting file: {0}. > preferences_loadException=Exception loading preferences from: {0}. > preferences_operationCanceled=Operation canceled. >-preferences_removeNodeException=Exception while removing preference node: {0}. >+preferences_clearNodeException=Exception while clearing preference node: {0}. > preferences_saveProblems=Exception occurred while saving project preferences: {0}. > preferences_syncException=Exception occurred while synchronizing node: {0}. >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 137398
:
82171
|
88401
|
97949
|
97991