summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEgidijus Vaishnora2011-07-22 04:43:44 (EDT)
committerEgidijus Vaishnora2011-07-22 04:43:44 (EDT)
commit2a06d51331343837109c30c5161bf81cf866f811 (patch)
tree2aec7c37b15936b0dd011246e09407151d2aa462
parent1036f1d4827c74af0863403cf35f482f201676b7 (diff)
downloadcdo-2a06d51331343837109c30c5161bf81cf866f811.zip
cdo-2a06d51331343837109c30c5161bf81cf866f811.tar.gz
cdo-2a06d51331343837109c30c5161bf81cf866f811.tar.bz2
352303: [DB] null blob is not read from the DB store
https://bugs.eclipse.org/bugs/show_bug.cgi?id=352303
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java10
-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_352303_Test.java71
3 files changed, 82 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
index ee39ca7..6c973d3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
@@ -169,6 +169,11 @@ public class CoreTypeMappings
public Object getResultSetValue(ResultSet resultSet) throws SQLException
{
String str = resultSet.getString(getField().getName());
+ if (str == null)
+ {
+ return null;
+ }
+
int pos = str.indexOf('-');
byte[] id = HexUtil.hexToBytes(str.substring(0, pos));
@@ -216,6 +221,11 @@ public class CoreTypeMappings
public Object getResultSetValue(ResultSet resultSet) throws SQLException
{
String str = resultSet.getString(getField().getName());
+ if (str == null)
+ {
+ return null;
+ }
+
int pos = str.indexOf('-');
byte[] id = HexUtil.hexToBytes(str.substring(0, pos));
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 9235c7f..14f8b6b 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
@@ -235,5 +235,6 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_351096_Test.class);
testClasses.add(Bugzilla_338921_Test.class);
testClasses.add(Bugzilla_351393_Test.class);
+ testClasses.add(Bugzilla_352303_Test.class);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java
new file mode 100644
index 0000000..5f135ac
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_352303_Test.java
@@ -0,0 +1,71 @@
+/**
+ * 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.model3.Image;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.io.IOUtil;
+
+import java.io.InputStream;
+
+/**
+ * @author Eike Stepper
+ */
+public class Bugzilla_352303_Test extends AbstractCDOTest
+{
+ @CleanRepositoriesBefore
+ public void testReadBlob() throws Exception
+ {
+ commitBlob();
+
+ getRepository().getRevisionManager().getCache().clear();
+
+ CDOSession session = openSession();
+ CDOView view = session.openView();
+ CDOResource resource = view.getResource(getResourcePath("res"));
+
+ Image image = (Image)resource.getContents().get(0);
+ assertEquals(320, image.getWidth());
+ assertEquals(200, image.getHeight());
+
+ CDOBlob blob = image.getData();
+ assertEquals(null, blob);
+ }
+
+ private void commitBlob() throws Exception
+ {
+ InputStream inputStream = null;
+
+ try
+ {
+ Image image = getModel3Factory().createImage();
+ image.setWidth(320);
+ image.setHeight(200);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("res"));
+ resource.getContents().add(image);
+
+ transaction.commit();
+ }
+ finally
+ {
+ IOUtil.close(inputStream);
+ }
+ }
+}