Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java74
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java33
4 files changed, 84 insertions, 41 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java
index f9565f292a..9b1130aa59 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java
@@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.ref.Interner;
import java.io.IOException;
@@ -31,13 +32,15 @@ public final class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExter
{
private static final long serialVersionUID = 1L;
+ private static final boolean checkFragment = OMPlatform.INSTANCE.isProperty("org.eclipse.emf.cdo.common.id.CDOIDExternal.checkFragment");
+
private static final StringInterner INTERNER = new StringInterner();
private final String uri;
private CDOIDExternalImpl(String uri)
{
- CheckUtil.checkArg(uri, "Null not allowed");
+ checkURI(uri);
this.uri = uri;
}
@@ -119,6 +122,16 @@ public final class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExter
return uri.hashCode();
}
+ static void checkURI(String uri)
+ {
+ CheckUtil.checkArg(uri, "Null not allowed");
+
+ if (checkFragment)
+ {
+ CheckUtil.checkArg(!uri.endsWith("#NNULL"), "Fragment 'NNULL' not allowed");
+ }
+ }
+
public static CDOIDExternalImpl create(String uri)
{
return INTERNER.intern(uri);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java
index 39b69521f7..eb4e356a55 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java
@@ -18,7 +18,6 @@ import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.ref.Interner;
import java.io.IOException;
@@ -38,7 +37,7 @@ public final class CDOIDTempObjectExternalImpl extends AbstractCDOID implements
private CDOIDTempObjectExternalImpl(String uri)
{
- CheckUtil.checkArg(uri, "Null not allowed");
+ CDOIDExternalImpl.checkURI(uri);
this.uri = uri;
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
index a84f613b6f..79ea70ff09 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334995_Test.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.tests.bugzilla;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
@@ -17,6 +18,8 @@ import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CommitException;
+import java.util.Map.Entry;
+
/**
* Bug 334995 - CDOTransaction corrupted by persisted + new resource with same URI
*
@@ -24,40 +27,41 @@ import org.eclipse.emf.cdo.util.CommitException;
*/
public class Bugzilla_334995_Test extends AbstractCDOTest
{
- // The following test seems obsolete because (as of bug xxxxxx) no local changes can create resource duplicates.
- //
- // public void test() throws CommitException
- // {
- // CDOID[] resourceIDs = persistResources("/res1");
- //
- // {
- // CDOSession session = openSession();
- // CDOTransaction transaction = session.openTransaction();
- //
- // CDOResource resource = transaction.createResource(getResourcePath("/res1"));
- // msg("New resource: " + resource);
- // msg("newObjects:");
- //
- // for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
- // {
- // msg(" " + entry + ", state: " + entry.getValue().cdoState());
- // assertNew(entry.getValue(), transaction);
- // }
- //
- // // Fetch the persisted resource that has the same URI
- // CDOResource resource1 = (CDOResource)transaction.getObject(resourceIDs[0]);
- // msg("Persisted resource: " + resource1);
- //
- // msg("newObjects:");
- // for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
- // {
- // msg(" " + entry + ", state: " + entry.getValue().cdoState());
- // assertNew(entry.getValue(), transaction);
- // }
- //
- // transaction.commit();
- // }
- // }
+ /**
+ * The following test seems obsolete because (as of bug xxxxxx) no local changes can create resource duplicates.
+ */
+ public void _test() throws CommitException
+ {
+ CDOID resourceID = persistResources("/res1")[0];
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ msg("New resource: " + resource);
+ msg("newObjects:");
+
+ for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
+ {
+ msg(" " + entry + ", state: " + entry.getValue().cdoState());
+ assertNew(entry.getValue(), transaction);
+ }
+
+ // Fetch the persisted resource that has the same URI
+ CDOResource resource1 = (CDOResource)transaction.getObject(resourceID);
+ msg("Persisted resource: " + resource1);
+
+ msg("newObjects:");
+ for (Entry<CDOID, CDOObject> entry : transaction.getNewObjects().entrySet())
+ {
+ msg(" " + entry + ", state: " + entry.getValue().cdoState());
+ assertNew(entry.getValue(), transaction);
+ }
+
+ transaction.commit();
+ }
+ }
public void testRename() throws CommitException
{
@@ -75,8 +79,6 @@ public class Bugzilla_334995_Test extends AbstractCDOTest
resource1.getContents().add(getModel1Factory().createAddress());
resource2.getContents().add(getModel1Factory().createAddress());
transaction.commit();
-
- session.close();
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java
index 795e31f25a..d210bd5bac 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/io/IOUtil.java
@@ -281,11 +281,14 @@ public final class IOUtil
return openWriter(new File(fileName));
}
- public static FileWriter openWriter(File file) throws IORuntimeException
+ /**
+ * @since 3.9
+ */
+ public static FileWriter openWriter(File file, boolean append) throws IORuntimeException
{
try
{
- return new FileWriter(file);
+ return new FileWriter(file, append);
}
catch (IOException ex)
{
@@ -293,6 +296,11 @@ public final class IOUtil
}
}
+ public static FileWriter openWriter(File file) throws IORuntimeException
+ {
+ return openWriter(file, false);
+ }
+
public static Exception closeSilent(Closeable closeable)
{
try
@@ -814,6 +822,27 @@ public final class IOUtil
}
}
+ /**
+ * @since 3.9
+ */
+ public static void writeText(File file, boolean append, String text) throws IORuntimeException
+ {
+ FileWriter writer = openWriter(file, append);
+
+ try
+ {
+ writer.write(text);
+ }
+ catch (IOException ex)
+ {
+ throw new IORuntimeException(ex);
+ }
+ finally
+ {
+ closeSilent(writer);
+ }
+ }
+
public static List<File> listDepthFirst(File file)
{
FileCollector collector = new FileCollector();

Back to the top