sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1653013 - in /sling/trunk/bundles/jcr/resource/src: main/java/org/apache/sling/jcr/resource/internal/helper/JcrPropertyMapCacheEntry.java test/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMapTest.java
Date Mon, 19 Jan 2015 14:37:42 GMT
Author: bdelacretaz
Date: Mon Jan 19 14:37:42 2015
New Revision: 1653013

URL: http://svn.apache.org/r1653013
Log:
SLING-4307 - tentative fix for streams storage issue

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrPropertyMapCacheEntry.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMapTest.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrPropertyMapCacheEntry.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrPropertyMapCacheEntry.java?rev=1653013&r1=1653012&r2=1653013&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrPropertyMapCacheEntry.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/JcrPropertyMapCacheEntry.java
Mon Jan 19 14:37:42 2015
@@ -82,21 +82,31 @@ public class JcrPropertyMapCacheEntry {
         this.propertyValue = value;
         this.isArray = value.getClass().isArray();
         // check if values can be stored in JCR
+        // TODO this causes createValue to be called, we might
+        // want to store the result of that?? But maybe we expect
+        // future createValue to happen on a different node due to
+        // caching?
         if ( isArray ) {
             final Object[] values = convertToObjectArray(value);
             for(int i=0; i<values.length; i++) {
-                final Value val = this.createValue(values[i], node);
-                if ( val == null ) {
-                    throw new IllegalArgumentException("Value can't be stored in the repository:
" + values[i]);
-                }
+                failIfCannotStore(values[i], node);
             }
         } else {
-            final Value val = this.createValue(value, node);
-            if ( val == null ) {
-                throw new IllegalArgumentException("Value can't be stored in the repository:
" + value);
-            }
+            failIfCannotStore(value, node);
         }
      }
+    
+    private void failIfCannotStore(Object value, Node node) throws RepositoryException {
+        if(value instanceof InputStream) {
+            // InputStream is storable and calling createValue for nothing
+            // eats its contents
+            return;
+        }
+        final Value val = this.createValue(value, node);
+        if ( val == null ) {
+            throw new IllegalArgumentException("Value can't be stored in the repository:
" + value);
+        }
+    }
 
     /**
      * Create a value for the object.

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMapTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMapTest.java?rev=1653013&r1=1653012&r2=1653013&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMapTest.java
(original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMapTest.java
Mon Jan 19 14:37:42 2015
@@ -40,7 +40,6 @@ import org.apache.sling.api.resource.Mod
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.commons.testing.jcr.RepositoryTestBase;
 import org.apache.sling.jcr.resource.JcrResourceUtil;
-import org.apache.sling.jcr.resource.internal.helper.jcr.JcrItemResourceTestBase;
 
 public class JcrModifiableValueMapTest extends RepositoryTestBase {
 
@@ -82,8 +81,7 @@ public class JcrModifiableValueMapTest e
         return values;
     }
 
-    // SLING-4307 introduced a regresssion that makes this test fail
-    public void DISABLED_testStreams() throws Exception {
+    public void testStreams() throws Exception {
         final ModifiableValueMap pvm = new JcrModifiableValueMap(this.rootNode, null);
         InputStream stream = new ByteArrayInputStream(TEST_BYTE_ARRAY);
         pvm.put("binary", stream);



Mime
View raw message