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 97991 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]
The patch is smaller now, but better
137398_20080429.txt (text/plain), 7.63 KB, created by
Szymon Brandys
on 2008-04-29 10:42:28 EDT
(
hide
)
Description:
The patch is smaller now, but better
Filename:
MIME Type:
Creator:
Szymon Brandys
Created:
2008-04-29 10:42:28 EDT
Size:
7.63 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 14:41:34 -0000 >@@ -894,7 +894,8 @@ > assertTrue("3.1", !fileInFS.exists()); > IEclipsePreferences projectNode = (IEclipsePreferences) service.getRootNode().node(ProjectScope.SCOPE).node(project.getName()); > try { >- assertTrue("3.2", !projectNode.nodeExists(qualifier)); >+ // when the pref file is deleted, its node will be cleared, but not removed >+ assertTrue("3.2", isNodeCleared(projectNode, new String[]{qualifier})); > } catch (BackingStoreException e) { > fail("3.91", e); > } >@@ -921,4 +922,23 @@ > node = context.getNode(qualifier); > assertEquals("5.0", newValue, 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; >+ } > } >#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 14:41:36 -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 14:41:35 -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)) >@@ -257,6 +251,32 @@ > i.remove(); > } > } >+ >+ 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 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 { >+ 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); >+ } >+ String path = node.absolutePath(); >+ for (Iterator i = loadedNodes.iterator(); i.hasNext();) { >+ String key = (String) i.next(); >+ if (key.startsWith(path)) >+ i.remove(); >+ } >+ } > > public static void updatePreferences(IFile file) throws CoreException { > IPath path = file.getFullPath(); >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 14:41:36 -0000 >@@ -106,6 +106,7 @@ > 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 14:41:36 -0000 >@@ -102,6 +102,7 @@ > 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