Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-08-07 03:24:06 -0400
committerEike Stepper2013-08-07 03:24:06 -0400
commit3313e6995f65ca086df6ac1303dd5b4ef70f3fd2 (patch)
tree642bf2ab27ef8dba0ece179e7c196371bff2de9c
parent843fb3a079b79d19266f614182fa635c829e1243 (diff)
downloadcdo-3313e6995f65ca086df6ac1303dd5b4ef70f3fd2.tar.gz
cdo-3313e6995f65ca086df6ac1303dd5b4ef70f3fd2.tar.xz
cdo-3313e6995f65ca086df6ac1303dd5b4ef70f3fd2.zip
[414270] Do not access sub branches if repository does not support
branching https://bugs.eclipse.org/bugs/show_bug.cgi?id=414270
-rw-r--r--plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF68
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_414270_Test.java123
4 files changed, 196 insertions, 37 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF
index eca69f5022..740f476366 100644
--- a/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.emf.cdo.common
-Bundle-Version: 4.2.0.qualifier
+Bundle-Version: 4.2.1.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -14,21 +14,21 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";visibili
org.eclipse.emf.ecore.change;bundle-version="[2.5.0,3.0.0)";visibility:=reexport,
org.eclipse.emf.ecore.xmi;bundle-version="[2.5.0,3.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
- org.eclipse.emf.cdo.common.admin;version="4.2.0",
- org.eclipse.emf.cdo.common.branch;version="4.2.0",
- org.eclipse.emf.cdo.common.commit;version="4.2.0",
- org.eclipse.emf.cdo.common.commit.handler;version="4.2.0",
- org.eclipse.emf.cdo.common.id;version="4.2.0",
- org.eclipse.emf.cdo.common.lob;version="4.2.0",
- org.eclipse.emf.cdo.common.lock;version="4.2.0",
- org.eclipse.emf.cdo.common.model;version="4.2.0",
- org.eclipse.emf.cdo.common.protocol;version="4.2.0",
- org.eclipse.emf.cdo.common.revision;version="4.2.0",
- org.eclipse.emf.cdo.common.revision.delta;version="4.2.0",
- org.eclipse.emf.cdo.common.security;version="4.2.0",
- org.eclipse.emf.cdo.common.util;version="4.2.0",
- org.eclipse.emf.cdo.internal.common;version="4.2.0";
+Export-Package: org.eclipse.emf.cdo.common;version="4.2.1",
+ org.eclipse.emf.cdo.common.admin;version="4.2.1",
+ org.eclipse.emf.cdo.common.branch;version="4.2.1",
+ org.eclipse.emf.cdo.common.commit;version="4.2.1",
+ org.eclipse.emf.cdo.common.commit.handler;version="4.2.1",
+ org.eclipse.emf.cdo.common.id;version="4.2.1",
+ org.eclipse.emf.cdo.common.lob;version="4.2.1",
+ org.eclipse.emf.cdo.common.lock;version="4.2.1",
+ org.eclipse.emf.cdo.common.model;version="4.2.1",
+ org.eclipse.emf.cdo.common.protocol;version="4.2.1",
+ org.eclipse.emf.cdo.common.revision;version="4.2.1",
+ org.eclipse.emf.cdo.common.revision.delta;version="4.2.1",
+ org.eclipse.emf.cdo.common.security;version="4.2.1",
+ org.eclipse.emf.cdo.common.util;version="4.2.1",
+ org.eclipse.emf.cdo.internal.common;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -38,11 +38,11 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.server.hibernate",
- org.eclipse.emf.cdo.internal.common.branch;version="4.2.0";
+ org.eclipse.emf.cdo.internal.common.branch;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.server.hibernate",
- org.eclipse.emf.cdo.internal.common.bundle;version="4.2.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.commit;version="4.2.0";
+ org.eclipse.emf.cdo.internal.common.bundle;version="4.2.1";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.commit;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -51,7 +51,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.common.id;version="4.2.0";
+ org.eclipse.emf.cdo.internal.common.id;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -62,9 +62,9 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.admin,
org.eclipse.emf.cdo.server.admin",
- org.eclipse.emf.cdo.internal.common.lock;version="4.2.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.messages;version="4.2.0";x-internal:=true,
- org.eclipse.emf.cdo.internal.common.model;version="4.2.0";
+ org.eclipse.emf.cdo.internal.common.lock;version="4.2.1";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.messages;version="4.2.1";x-internal:=true,
+ org.eclipse.emf.cdo.internal.common.model;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -73,7 +73,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.common.revision;version="4.2.0";
+ org.eclipse.emf.cdo.internal.common.revision;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -82,7 +82,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.internal.common.revision.delta;version="4.2.0";
+ org.eclipse.emf.cdo.internal.common.revision.delta;version="4.2.1";
x-friends:="org.eclipse.emf.cdo.common,
org.eclipse.emf.cdo.common.db,
org.eclipse.emf.cdo,
@@ -91,12 +91,12 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.2.0",
org.eclipse.emf.cdo.server.net4j,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.tests",
- org.eclipse.emf.cdo.spi.common;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.admin;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.branch;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.commit;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.id;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.lock;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.model;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.protocol;version="4.2.0",
- org.eclipse.emf.cdo.spi.common.revision;version="4.2.0"
+ org.eclipse.emf.cdo.spi.common;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.admin;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.branch;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.commit;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.id;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.lock;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.model;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.protocol;version="4.2.1",
+ org.eclipse.emf.cdo.spi.common.revision;version="4.2.1"
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
index 5b405f7086..5bfdbcd07a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Erdal Karaca - bug 414270: check if repository supports branching when querying sub branches
*/
package org.eclipse.emf.cdo.internal.common.branch;
@@ -30,7 +31,7 @@ import java.util.List;
*/
public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBranch
{
- public static final int ILLEGAL_BRANCH_ID = Integer.MIN_VALUE;
+ private static final InternalCDOBranch[] NO_BRANCHES = new InternalCDOBranch[0];
private InternalCDOBranchManager branchManager;
@@ -154,7 +155,12 @@ public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBr
public InternalCDOBranch createBranch(String name, long timeStamp)
{
- return getBranchManager().createBranch(BranchLoader.NEW_BRANCH, name, this, timeStamp);
+ if (!branchManager.getRepository().isSupportingBranches())
+ {
+ throw new IllegalStateException("Branching is not supported");
+ }
+
+ return branchManager.createBranch(BranchLoader.NEW_BRANCH, name, this, timeStamp);
}
public InternalCDOBranch createBranch(String name)
@@ -169,9 +175,13 @@ public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBr
public InternalCDOBranch[] getBranches(boolean loadOnDemand)
{
+ if (!branchManager.getRepository().isSupportingBranches())
+ {
+ return NO_BRANCHES;
+ }
+
if (branches == null && loadOnDemand)
{
- InternalCDOBranchManager branchManager = getBranchManager();
SubBranchInfo[] infos = branchManager.getBranchLoader().loadSubBranches(id);
branches = new InternalCDOBranch[infos.length];
for (int i = 0; i < infos.length; i++)
@@ -191,6 +201,11 @@ public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBr
public InternalCDOBranch getBranch(String path)
{
+ if (!branchManager.getRepository().isSupportingBranches())
+ {
+ return null;
+ }
+
while (path.startsWith(PATH_SEPARATOR))
{
path = path.substring(1);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java
index 780ee4364f..b5b9f468d2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java
@@ -112,6 +112,11 @@ public class CDOBranchManagerImpl extends Container<CDOBranch> implements Intern
return mainBranch;
}
+ if (!repository.isSupportingBranches())
+ {
+ return null;
+ }
+
InternalCDOBranch branch;
synchronized (branches)
{
@@ -171,6 +176,11 @@ public class CDOBranchManagerImpl extends Container<CDOBranch> implements Intern
return null;
}
+ if (!repository.isSupportingBranches())
+ {
+ return null;
+ }
+
String name = path.substring(0, sep);
if (CDOBranch.MAIN_BRANCH_NAME.equals(name))
{
@@ -184,6 +194,17 @@ public class CDOBranchManagerImpl extends Container<CDOBranch> implements Intern
public int getBranches(int startID, int endID, CDOBranchHandler handler)
{
checkActive();
+ if (!repository.isSupportingBranches())
+ {
+ if (startID <= CDOBranch.MAIN_BRANCH_ID && CDOBranch.MAIN_BRANCH_ID <= endID)
+ {
+ handler.handleBranch(mainBranch);
+ return 1;
+ }
+
+ return 0;
+ }
+
return branchLoader.loadBranches(startID, endID, handler);
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_414270_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_414270_Test.java
new file mode 100644
index 0000000000..fd9fd9c5d6
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_414270_Test.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2013 Eike Stepper (Berlin, Germany) 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:
+ * Esteban Dugueperoux - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Skips;
+
+/**
+ * Bug 414270: Do not access sub branches if repository does not support branching.
+ *
+ * @author Eike Stepper
+ */
+@Skips(IRepositoryConfig.CAPABILITY_BRANCHING)
+public class Bugzilla_414270_Test extends AbstractCDOTest
+{
+ public void testGetBranches() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch[] branches = mainBranch.getBranches();
+ assertEquals(0, branches.length);
+ }
+
+ public void testGetBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+ CDOBranch branch = mainBranch.getBranch("blabla");
+ assertEquals(null, branch);
+ }
+
+ public void testCreateBranch() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranch mainBranch = session.getBranchManager().getMainBranch();
+
+ try
+ {
+ mainBranch.createBranch("blabla");
+ fail("IllegalStateException expected");
+ }
+ catch (IllegalStateException expected)
+ {
+ // SUCCESS
+ }
+ }
+
+ public void testManagerGetBranchByID() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getBranch(CDOBranch.MAIN_BRANCH_ID);
+ assertEquals(branchManager.getMainBranch(), mainBranch);
+
+ CDOBranch branch = branchManager.getBranch(4711);
+ assertEquals(null, branch);
+ }
+
+ public void testManagerGetBranchByPath() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranchManager branchManager = session.getBranchManager();
+ CDOBranch mainBranch = branchManager.getBranch(CDOBranch.MAIN_BRANCH_NAME);
+ assertEquals(branchManager.getMainBranch(), mainBranch);
+
+ CDOBranch branch = branchManager.getBranch("/MAIN/blabla");
+ assertEquals(null, branch);
+ }
+
+ public void testManagerQuery() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ final CDOBranch[] result = { null };
+ int count = branchManager.getBranches(CDOBranch.MAIN_BRANCH_ID, CDOBranch.MAIN_BRANCH_ID + 1,
+ new CDOBranchHandler()
+ {
+ public void handleBranch(CDOBranch branch)
+ {
+ if (result[0] != null)
+ {
+ fail("Only one result branch expected: the main branch");
+ }
+
+ result[0] = branch;
+ }
+ });
+
+ assertEquals(1, count);
+ assertEquals(branchManager.getMainBranch(), result[0]);
+ }
+
+ public void testManagerQueryNoResult() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOBranchManager branchManager = session.getBranchManager();
+
+ int count = branchManager.getBranches(CDOBranch.MAIN_BRANCH_ID + 1, CDOBranch.MAIN_BRANCH_ID + 2,
+ new CDOBranchHandler()
+ {
+ public void handleBranch(CDOBranch branch)
+ {
+ fail("No result branch expected");
+ }
+ });
+
+ assertEquals(0, count);
+ }
+}

Back to the top