From ff152a15474a4e44ae72b5a25613dc1f3aa74749 Mon Sep 17 00:00:00 2001 From: Egidijus Vaishnora Date: Thu, 7 Jul 2011 07:26:57 +0000 Subject: [351096] Fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=351096 --- .../eclipse/emf/cdo/spi/server/StoreAccessor.java | 5 +- .../src/org/eclipse/emf/cdo/tests/AllConfigs.java | 1 + .../cdo/tests/bugzilla/Bugzilla_351096_Test.java | 105 +++++++++++++++++++++ 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_351096_Test.java (limited to 'plugins') 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 -- cgit v1.2.3