summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaishnora2011-07-05 06:48:01 (EDT)
committerEgidijus Vaishnora2011-07-05 06:48:01 (EDT)
commit5c9815ec29491aec1433b5175d32c2c9a758087a (patch)
treed4b7404c6f0dcbff2047a329ba046e68f2621bc2
parentc5bd1bac9c209439fcca7e7d3f2bf2addb66da37 (diff)
downloadcdo-5c9815ec29491aec1433b5175d32c2c9a758087a.zip
cdo-5c9815ec29491aec1433b5175d32c2c9a758087a.tar.gz
cdo-5c9815ec29491aec1433b5175d32c2c9a758087a.tar.bz2
[351067] Fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=351067
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java75
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java13
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/ByteArrayWrapper.java76
5 files changed, 160 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
index 6afe13c..5685062 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/mem/MEMStore.java
@@ -809,7 +809,7 @@ public class MEMStore extends LongIDStore implements IMEMStore, BranchLoader, Du
{
byte[] id = it.next();
String key = HexUtil.bytesToHex(id);
- if (lobs.containsKey(key))
+ if (!lobs.containsKey(key))
{
it.remove();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index db2c538..7dbb336 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -231,5 +231,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_349793_Test.class);
testClasses.add(Bugzilla_349804_Test.class);
testClasses.add(Bugzilla_350027_Test.class);
+ testClasses.add(Bugzilla_351067_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java
new file mode 100644
index 0000000..527e684
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351067_Test.java
@@ -0,0 +1,75 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.lob.CDOBlob;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.bundle.OM;
+import org.eclipse.emf.cdo.tests.model3.Image;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.InputStream;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_351067_Test extends AbstractCDOTest
+{
+ public void testCommitBlob() throws Exception
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+
+ InputStream inputStream = null;
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+
+ try
+ {
+ inputStream = OM.BUNDLE.getInputStream("copyright.txt");
+ CDOBlob blob = new CDOBlob(inputStream);
+
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index da094f5..ceda524 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -103,6 +103,7 @@ import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.collection.ByteArrayWrapper;
import org.eclipse.net4j.util.collection.FastList;
import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.event.IEvent;
@@ -2254,7 +2255,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
*/
private boolean isPartialCommit;
- private Map<byte[], CDOLob<?>> lobs = new HashMap<byte[], CDOLob<?>>();
+ private Map<ByteArrayWrapper, CDOLob<?>> lobs = new HashMap<ByteArrayWrapper, CDOLob<?>>();
public CDOCommitContextImpl(InternalCDOTransaction transaction)
{
@@ -2417,11 +2418,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
if (!lobs.isEmpty())
{
CDOSessionProtocol sessionProtocol = getSession().getSessionProtocol();
- List<byte[]> alreadyKnown = sessionProtocol.queryLobs(lobs.keySet());
+ List<byte[]> alreadyKnown = sessionProtocol.queryLobs(ByteArrayWrapper.toByteArray(lobs.keySet()));
for (byte[] id : alreadyKnown)
{
- lobs.remove(id);
+ lobs.remove(new ByteArrayWrapper(id));
}
}
}
@@ -2555,7 +2556,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return commitInfoManager.createCommitInfo(branch, timeStamp, previousTimeStamp, userID, comment, commitData);
}
- private void preCommit(Map<CDOID, CDOObject> objects, Map<byte[], CDOLob<?>> lobs)
+ private void preCommit(Map<CDOID, CDOObject> objects, Map<ByteArrayWrapper, CDOLob<?>> lobs)
{
if (!objects.isEmpty())
{
@@ -2573,7 +2574,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
- private void collectLobs(InternalCDORevision revision, Map<byte[], CDOLob<?>> lobs)
+ private void collectLobs(InternalCDORevision revision, Map<ByteArrayWrapper, CDOLob<?>> lobs)
{
EStructuralFeature[] features = revision.getClassInfo().getAllPersistentFeatures();
for (int i = 0; i < features.length; i++)
@@ -2584,7 +2585,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
CDOLob<?> lob = (CDOLob<?>)revision.getValue(feature);
if (lob != null)
{
- lobs.put(lob.getID(), lob);
+ lobs.put(new ByteArrayWrapper(lob.getID()), lob);
}
}
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/ByteArrayWrapper.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/ByteArrayWrapper.java
new file mode 100644
index 0000000..e73bb31
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/ByteArrayWrapper.java
@@ -0,0 +1,76 @@
+/**
+ * Copyright (c) 2004 - 2011 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.collection;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public final class ByteArrayWrapper
+{
+ private final byte[] data;
+
+ public ByteArrayWrapper(byte[] data)
+ {
+ CheckUtil.checkArg(data, "data");
+ this.data = data;
+ }
+
+ public byte[] getData()
+ {
+ return data;
+ }
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof ByteArrayWrapper)
+ {
+ return Arrays.equals(data, ((ByteArrayWrapper)other).data);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Arrays.hashCode(data);
+ }
+
+ @Override
+ public String toString()
+ {
+ return data.toString();
+ }
+
+ public static Set<byte[]> toByteArray(Set<ByteArrayWrapper> wrappers)
+ {
+ if (wrappers == null)
+ {
+ return null;
+ }
+
+ Set<byte[]> result = new HashSet<byte[]>();
+ for (ByteArrayWrapper wrapper : wrappers)
+ {
+ result.add(wrapper.getData());
+ }
+
+ return result;
+ }
+}