jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r1485097 - in /jackrabbit/oak/trunk/oak-jcr/src: main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Date Wed, 22 May 2013 07:14:35 GMT
Author: jukka
Date: Wed May 22 07:14:35 2013
New Revision: 1485097

URL: http://svn.apache.org/r1485097
Log:
OAK-510: Multivalued properties with array size 0 forget their type

Default to string when no other type hints are available

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java?rev=1485097&r1=1485096&r2=1485097&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/ItemImpl.java
Wed May 22 07:14:35 2013
@@ -430,8 +430,12 @@ abstract class ItemImpl<T extends ItemDe
         Value[] nonNullValues = compact(values);
         int targetType = getType(definition, type);
         if (nonNullValues.length == 0) {
+            if (targetType == PropertyType.UNDEFINED) {
+                // default to string when no other type hints are available
+                targetType = PropertyType.STRING;
+            }
             return MemoryPropertyBuilder
-                    .array(Type.fromTag(type, false), name)
+                    .array(Type.fromTag(targetType, false), name)
                     .getPropertyState();
         } else if (targetType == type) {
             return PropertyStates.createProperty(name, Arrays.asList(nonNullValues));

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java?rev=1485097&r1=1485096&r2=1485097&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java
Wed May 22 07:14:35 2013
@@ -787,6 +787,26 @@ public class RepositoryTest extends Abst
     }
 
     @Test
+    public void addEmptyMultiValue() throws RepositoryException {
+        Node parentNode = getNode(TEST_PATH);
+        Value[] values = new Value[0];
+
+        parentNode.setProperty("multi value", values);
+        parentNode.getSession().save();
+
+        Session session2 = createAnonymousSession();
+        try {
+            Property property = session2.getProperty(TEST_PATH + "/multi value");
+            assertTrue(property.isMultiple());
+            assertEquals(PropertyType.STRING, property.getType());
+            Value[] values2 = property.getValues();
+            assertEquals(0, values2.length);
+        } finally {
+            session2.logout();
+        }
+    }
+
+    @Test
     public void addEmptyMultiValueName() throws RepositoryException {
         Node parentNode = getNode(TEST_PATH);
         Value[] values = new Value[0];



Mime
View raw message