Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaishnora2011-07-07 07:26:57 +0000
committerEgidijus Vaishnora2011-07-07 07:26:57 +0000
commitff152a15474a4e44ae72b5a25613dc1f3aa74749 (patch)
treed53f32eec003fdaa4f4142bb6d25b2eb27107e23
parent1db6ed552d142478f7df15fa798ee53d9b558088 (diff)
downloadcdo-ff152a15474a4e44ae72b5a25613dc1f3aa74749.tar.gz
cdo-ff152a15474a4e44ae72b5a25613dc1f3aa74749.tar.xz
cdo-ff152a15474a4e44ae72b5a25613dc1f3aa74749.zip
[351096] Fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=351096
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java5
-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_351096_Test.java105
3 files changed, 109 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
index 5625d151d7..9f3805b007 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/StoreAccessor.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.LimitedInputStream;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import java.io.IOException;
@@ -112,11 +113,11 @@ public abstract class StoreAccessor extends StoreAccessorBase
long size = in.readLong();
if (size > 0)
{
- writeBlob(id, size, in);
+ writeBlob(id, size, new LimitedInputStream(in, size));
}
else
{
- writeClob(id, -size, new InputStreamReader(in));
+ writeClob(id, -size, new InputStreamReader(new LimitedInputStream(in, -size)));
}
}
}
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 7dbb336888..cb167624d8 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
@@ -232,5 +232,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_349804_Test.class);
testClasses.add(Bugzilla_350027_Test.class);
testClasses.add(Bugzilla_351067_Test.class);
+ testClasses.add(Bugzilla_351096_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java
new file mode 100644
index 0000000000..71f01e3889
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java
@@ -0,0 +1,105 @@
+/**
+ * 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.common.lob.CDOClob;
+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.File;
+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.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+/**
+ * @author Egidijus Vaisnora
+ */
+public class Bugzilla_351096_Test extends AbstractCDOTest
+{
+ public void testCommit2Blob() 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);
+
+ inputStream = new ByteArrayInputStream("Just another stream".getBytes());
+ blob = new CDOBlob(inputStream);
+
+ image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+ image.setData(blob);
+
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+
+ public void testCommit2Clob() 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");
+ CDOClob clob = new CDOClob(new InputStreamReader(inputStream));
+ File file = getModel3Factory().createFile();
+ file.setName("copyright.txt");
+ file.setData(clob);
+
+ resource.getContents().add(file);
+
+ inputStream = new ByteArrayInputStream("Just another stream".getBytes());
+ clob = new CDOClob(new InputStreamReader(inputStream));
+ file = getModel3Factory().createFile();
+ file.setName("xxx.txt");
+ file.setData(clob);
+
+ resource.getContents().add(file);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+} \ No newline at end of file

Back to the top