Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-07-28 00:19:07 -0400
committerEike Stepper2011-07-28 00:19:07 -0400
commite993f7385a908dbe204eb5d8ed326e7d68d9f721 (patch)
tree663c81f04a31f0f0cf030a47d0e4fb59b2cc18ef
parentb2044d502d4481e0b34a18311ff6739b16890ca2 (diff)
downloadcdo-e993f7385a908dbe204eb5d8ed326e7d68d9f721.tar.gz
cdo-e993f7385a908dbe204eb5d8ed326e7d68d9f721.tar.xz
cdo-e993f7385a908dbe204eb5d8ed326e7d68d9f721.zip
[353249] CDOTransaction/CDOView getResourceNode does not return null
https://bugs.eclipse.org/bugs/show_bug.cgi?id=353249
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java15
3 files changed, 32 insertions, 10 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
index 76529afe4f..ad6f8fa8c4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
@@ -1636,6 +1636,24 @@ public class ResourceTest extends AbstractCDOTest
}
/**
+ * See bug 353249.
+ */
+ public void testGetResourceNodeContract()
+ {
+ CDOView view = openSession().openView();
+
+ try
+ {
+ view.getResourceNode("SomePath/That/DoesntExist");
+ fail("Exception expected");
+ }
+ catch (Exception expected)
+ {
+ // SUCCCESS
+ }
+ }
+
+ /**
* @author Eike Stepper
*/
private static class TestAdapter extends AdapterImpl
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
index fd19e0b1e7..bfe7d060d3 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOView.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceFolder;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
@@ -186,9 +187,13 @@ public interface CDOView extends CDOCommonView, CDOUpdatable, INotifier, IOption
public CDOResource getResource(String path);
/**
- * Returns the resource node with the given path, or <code>null</code> if no such resource node exists.
+ * Returns the resource node with the given path.
+ *
+ * @return never <code>null</code>.
+ * @throws CDOException
+ * if no such resource node exists.
*/
- public CDOResourceNode getResourceNode(String path);
+ public CDOResourceNode getResourceNode(String path) throws CDOException;
/**
* Returns the root resource of the repository.
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index 4e816e914c..2c481cdf2d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -310,18 +310,17 @@ public abstract class AbstractCDOView extends Lifecycle implements InternalCDOVi
public synchronized CDOResourceNode getResourceNode(String path)
{
CDOID id = getResourceNodeID(path);
- if (id == null)
+ if (id != null) // Should always be true
{
- return null;
- }
- InternalCDOObject object = getObject(id);
- if (object instanceof CDOResourceNode)
- {
- return (CDOResourceNode)object;
+ InternalCDOObject object = getObject(id);
+ if (object instanceof CDOResourceNode)
+ {
+ return (CDOResourceNode)object;
+ }
}
- return null;
+ throw new CDOException("Resource node not found: " + path);
}
/**

Back to the top