You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2014/01/30 08:01:58 UTC

svn commit: r1562702 - /sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java

Author: cziegeler
Date: Thu Jan 30 07:01:58 2014
New Revision: 1562702

URL: http://svn.apache.org/r1562702
Log:
SLING-3351 : org.apache.sling.jcr.resource.JcrResourceUtil.setProperty method doesn't handle primitive arrays

Modified:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java?rev=1562702&r1=1562701&r2=1562702&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceUtil.java Thu Jan 30 07:01:58 2014
@@ -19,6 +19,7 @@
 package org.apache.sling.jcr.resource;
 
 import java.io.InputStream;
+import java.lang.reflect.Array;
 import java.math.BigDecimal;
 import java.util.Calendar;
 import java.util.StringTokenizer;
@@ -174,10 +175,11 @@ public class JcrResourceUtil {
         if ( propertyValue == null ) {
             node.setProperty(propertyName, (String)null);
         } else if ( propertyValue.getClass().isArray() ) {
-            final Object[] values = (Object[])propertyValue;
-            final Value[] setValues = new Value[values.length];
-            for(int i=0; i<values.length; i++) {
-                setValues[i] = createValue(values[i], node.getSession());
+            final int length = Array.getLength(propertyValue);
+            final Value[] setValues = new Value[length];
+            for(int i=0; i<length; i++) {
+                final Object value = Array.get(propertyValue, i);
+                setValues[i] = createValue(value, node.getSession());
             }
             node.setProperty(propertyName, setValues);
         } else {