summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2012-03-05 08:56:01 (EST)
committer Szymon Ptaszkiewicz2012-03-05 08:56:01 (EST)
commit3e5707eaf8edead76e9345b1cf92313789bc8b45 (patch)
treec9d408581c7229177c32ea46d2be5a6ad41f8e90
parent4ea40760b3b7859ea85ed7b2cdf3399e24c1fbe0 (diff)
downloadeclipse.platform.resources-3e5707eaf8edead76e9345b1cf92313789bc8b45.zip
eclipse.platform.resources-3e5707eaf8edead76e9345b1cf92313789bc8b45.tar.gz
eclipse.platform.resources-3e5707eaf8edead76e9345b1cf92313789bc8b45.tar.bz2
Bug 316182 - Calling RepositoryProvider.getProvider(IProject pjct)refs/changes/44/5244/1
throws null pointer exception Change-Id: I27cf7d90fcdbdc9048d698d61745a4fd5df58c30
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java8
-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/resources/refresh/Bug316182RefreshProvider.java34
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/AllTests.java1
-rw-r--r--tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug316182.java55
5 files changed, 101 insertions, 3 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 632b040..4df06c6 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
@@ -2498,17 +2498,19 @@ public class Workspace extends PlatformObject implements IWorkspace, ICoreConsta
markerManager = new MarkerManager(this);
markerManager.startup(null);
synchronizer = new Synchronizer(this);
- refreshManager = new RefreshManager(this);
saveManager = new SaveManager(this);
saveManager.startup(null);
- //must start after save manager, because (read) access to tree is needed
- refreshManager.startup(null);
propertyManager = ResourcesCompatibilityHelper.createPropertyManager();
propertyManager.startup(monitor);
charsetManager = new CharsetManager(this);
charsetManager.startup(null);
contentDescriptionManager = new ContentDescriptionManager();
contentDescriptionManager.startup(null);
+ //must start after save manager, because (read) access to tree is needed
+ //must start after other managers to avoid potential cyclic dependency on uninitialized managers (see bug 316182)
+ //must start before alias manager (see bug 94829)
+ refreshManager = new RefreshManager(this);
+ refreshManager.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);
diff --git a/tests/org.eclipse.core.tests.resources/plugin.xml b/tests/org.eclipse.core.tests.resources/plugin.xml
index a71e4c6..1879212 100644
--- a/tests/org.eclipse.core.tests.resources/plugin.xml
+++ b/tests/org.eclipse.core.tests.resources/plugin.xml
@@ -522,6 +522,12 @@
class="org.eclipse.core.tests.resources.refresh.TestRefreshProvider"
name="org.eclipse.core.tests.resources.testRefreshProvider"/>
</extension>
+<extension
+ point="org.eclipse.core.resources.refreshProviders">
+ <refreshProvider
+ class="org.eclipse.core.tests.resources.refresh.Bug316182RefreshProvider"
+ name="org.eclipse.core.tests.resources.bug316182RefreshProvider"/>
+</extension>
<extension point="org.eclipse.core.runtime.preferences">
<modifier class="org.eclipse.core.tests.internal.resources.ProjectPreferenceModifyListener"/>
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/refresh/Bug316182RefreshProvider.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/refresh/Bug316182RefreshProvider.java
new file mode 100644
index 0000000..c8ca3b5
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/refresh/Bug316182RefreshProvider.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.refresh;
+
+import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.refresh.*;
+import org.eclipse.core.tests.resources.session.TestBug316182;
+
+/**
+ * Refresh provider depicting bug 316182.
+ */
+public class Bug316182RefreshProvider extends RefreshProvider {
+ @Override
+ public IRefreshMonitor installMonitor(IResource resource, IRefreshResult result) {
+ try {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("project_TestBug316182");
+ project.getPersistentProperties();
+ project.getDefaultCharset();
+ project.getContentTypeMatcher();
+ } catch (Exception e) {
+ // remember the exception
+ TestBug316182.CAUGHT_EXCEPTION = e;
+ }
+ return null;
+ }
+}
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 371c2f7..3b6faf3 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
@@ -54,6 +54,7 @@ public class AllTests extends TestCase {
suite.addTest(ProjectDescriptionDynamicTest.suite());
suite.addTest(TestBug202384.suite());
suite.addTest(TestBug369177.suite());
+ suite.addTest(TestBug316182.suite());
return suite;
}
}
diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug316182.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug316182.java
new file mode 100644
index 0000000..723df05
--- /dev/null
+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/session/TestBug316182.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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 junit.framework.Test;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.core.tests.resources.AutomatedTests;
+import org.eclipse.core.tests.resources.WorkspaceSessionTest;
+import org.eclipse.core.tests.session.WorkspaceSessionTestSuite;
+
+/**
+ * Test for bug 316182
+ */
+public class TestBug316182 extends WorkspaceSessionTest {
+ public static Exception CAUGHT_EXCEPTION = null;
+
+ public TestBug316182() {
+ super();
+ }
+
+ public TestBug316182(String name) {
+ super(name);
+ }
+
+ public void test01_prepareWorkspace() throws CoreException {
+ InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, true);
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IProject project = workspace.getRoot().getProject("project_TestBug316182");
+ ensureExistsInWorkspace(project, true);
+ workspace.save(true, getMonitor());
+ // reset last caught exception
+ CAUGHT_EXCEPTION = null;
+ }
+
+ public void test02_startWorkspace() {
+ InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES).putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, false);
+ if (CAUGHT_EXCEPTION != null) {
+ fail("Test failed", CAUGHT_EXCEPTION);
+ }
+ }
+
+ public static Test suite() {
+ return new WorkspaceSessionTestSuite(AutomatedTests.PI_RESOURCES_TESTS, TestBug316182.class);
+ }
+}