aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2012-02-29 06:28:58 (EST)
committerSzymon Ptaszkiewicz2012-02-29 06:28:58 (EST)
commit4ea40760b3b7859ea85ed7b2cdf3399e24c1fbe0 (patch)
tree62db3d44cce5b939525836a717cefd2b0ce171d1
parentb1902ed6db17843ed418309bdff863070ffcb99b (diff)
downloadeclipse.platform.resources-4ea40760b3b7859ea85ed7b2cdf3399e24c1fbe0.zip
eclipse.platform.resources-4ea40760b3b7859ea85ed7b2cdf3399e24c1fbe0.tar.gz
eclipse.platform.resources-4ea40760b3b7859ea85ed7b2cdf3399e24c1fbe0.tar.bz2
Bug 369177 - DebugPlugin.start() generates NPE if activated early inv20120229-1128refs/changes/84/5184/1
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java7
-rw-r--r--tests/org.eclipse.core.tests.resources/plugin.xml6
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java43
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java59
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllTests.java3
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug369177.java52
6 files changed, 166 insertions, 4 deletions
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java
index a4288f1..632b040 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -2503,14 +2503,15 @@ public class Workspace extends PlatformObject implements IWorkspace, ICoreConsta
saveManager.startup(null);
//must start after save manager, because (read) access to tree is needed
refreshManager.startup(null);
- aliasManager = new AliasManager(this);
- aliasManager.startup(null);
propertyManager = ResourcesCompatibilityHelper.createPropertyManager();
propertyManager.startup(monitor);
charsetManager = new CharsetManager(this);
charsetManager.startup(null);
contentDescriptionManager = new ContentDescriptionManager();
contentDescriptionManager.startup(null);
+ //must start at the end to avoid potential cyclic dependency on other uninitialized managers (see bug 369177)
+ aliasManager = new AliasManager(this);
+ aliasManager.startup(null);
} finally {
//unlock tree even in case of failure, otherwise shutdown will also fail
treeLocked = null;
diff --git a/tests/org.eclipse.core.tests.resources/plugin.xml b/tests/org.eclipse.core.tests.resources/plugin.xml
index dfc9452..a71e4c6 100644
--- a/tests/org.eclipse.core.tests.resources/plugin.xml
+++ b/tests/org.eclipse.core.tests.resources/plugin.xml
@@ -551,6 +551,12 @@
</filesystem>
</extension>
<extension
+ point="org.eclipse.core.filesystem.filesystems">
+ <filesystem scheme="bug369177">
+ <run class="org.eclipse.core.tests.internal.filesystem.bug369177.Bug369177FileSystem"/>
+ </filesystem>
+</extension>
+<extension
id="modelProvider"
point="org.eclipse.core.resources.modelProviders">
<modelProvider
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java
new file mode 100644
index 0000000..19936d6
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileStore.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.tests.internal.filesystem.bug369177;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.eclipse.core.filesystem.IFileSystem;
+import org.eclipse.core.internal.filesystem.NullFileStore;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Special file store implementation used by TestBug369177.
+ */
+public class Bug369177FileStore extends NullFileStore {
+ private IPath path;
+
+ public Bug369177FileStore(IPath path) {
+ super(path);
+ this.path = path;
+ }
+
+ @Override
+ public IFileSystem getFileSystem() {
+ return Bug369177FileSystem.getInstance();
+ }
+
+ @Override
+ public URI toURI() {
+ try {
+ return new URI(Bug369177FileSystem.SCHEME_BUG_369177, null, path.isEmpty() ? "/" : path.toString(), null);
+ } catch (URISyntaxException e) {
+ throw new Error(e);
+ }
+ }
+}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java
new file mode 100644
index 0000000..be39306
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/filesystem/bug369177/Bug369177FileSystem.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.tests.internal.filesystem.bug369177;
+
+import java.net.URI;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.IFileSystem;
+import org.eclipse.core.internal.filesystem.NullFileSystem;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
+
+/**
+ * Special file system implementation used by TestBug369177.
+ */
+public class Bug369177FileSystem extends NullFileSystem {
+ static final String SCHEME_BUG_369177 = "bug369177";
+ private static IFileSystem instance;
+
+ public static IFileSystem getInstance() {
+ return instance;
+ }
+
+ public Bug369177FileSystem() {
+ super();
+ instance = this;
+ }
+
+ private void runTestScenario() {
+ try {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("project");
+ project.getPersistentProperties();
+ project.getDefaultCharset();
+ project.getContentTypeMatcher();
+ } catch (CoreException e) {
+ throw new Error(e);
+ }
+ }
+
+ @Override
+ public IFileStore getStore(IPath path) {
+ runTestScenario();
+ return new Bug369177FileStore(path);
+ }
+
+ @Override
+ public IFileStore getStore(URI uri) {
+ runTestScenario();
+ return new Bug369177FileStore(new Path(uri.getPath()));
+ }
+}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllTests.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllTests.java
index d6e8638..371c2f7 100644
--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllTests.java
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 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
@@ -53,6 +53,7 @@ public class AllTests extends TestCase {
suite.addTest(org.eclipse.core.tests.resources.usecase.SnapshotTest.suite());
suite.addTest(ProjectDescriptionDynamicTest.suite());
suite.addTest(TestBug202384.suite());
+ suite.addTest(TestBug369177.suite());
return suite;
}
}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug369177.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug369177.java
new file mode 100644
index 0000000..49873de
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug369177.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.tests.resources.session;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import junit.framework.Test;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.tests.resources.AutomatedTests;
+import org.eclipse.core.tests.resources.WorkspaceSessionTest;
+import org.eclipse.core.tests.session.WorkspaceSessionTestSuite;
+
+/**
+ * Test for bug 369177
+ */
+public class TestBug369177 extends WorkspaceSessionTest {
+ public TestBug369177() {
+ super();
+ }
+
+ public TestBug369177(String name) {
+ super(name);
+ }
+
+ public void test01_prepareWorkspace() throws CoreException, URISyntaxException {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject("project");
+ ensureExistsInWorkspace(project, true);
+
+ IFile link = project.getFile("link_to_file");
+ link.createLink(new URI("bug369177:/dummy_path.txt"), IResource.ALLOW_MISSING_LOCAL, getMonitor());
+
+ workspace.save(true, getMonitor());
+ }
+
+ public void test02_startWorkspace() {
+ // nothing to do, if we get this far without an error then we have already passed the test
+ }
+
+ public static Test suite() {
+ return new WorkspaceSessionTestSuite(AutomatedTests.PI_RESOURCES_TESTS, TestBug369177.class);
+ }
+}