You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2018/11/12 10:37:34 UTC

[GitHub] stefanseifert closed pull request #3: SLING-8066 MockProperty.setValue(final String[] newValues) throws null pointer exception

stefanseifert closed pull request #3: SLING-8066 MockProperty.setValue(final String[] newValues)  throws null pointer exception
URL: https://github.com/apache/sling-org-apache-sling-testing-jcr-mock/pull/3
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java b/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
index 291a165..5a5bb75 100644
--- a/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
+++ b/src/main/java/org/apache/sling/testing/mock/jcr/MockProperty.java
@@ -86,9 +86,12 @@ public void setValue(final Value newValue) throws RepositoryException {
 
     @Override
     public void setValue(final Value[] newValues) throws RepositoryException {
-        Value[] values = new Value[newValues.length];
-        for (int i = 0; i < newValues.length; i++) {
-            values[i] = newValues[i];
+        Value[] values = null;
+        if(newValues!=null){
+            values = new Value[newValues.length];
+            for (int i = 0; i < newValues.length; i++) {
+                values[i] = newValues[i];
+            }
         }
         this.itemData.setValues(values);
         this.itemData.setMultiple(true);
@@ -102,9 +105,12 @@ public void setValue(final String newValue) throws RepositoryException {
 
     @Override
     public void setValue(final String[] newValues) throws RepositoryException {
-        Value[] values = new Value[newValues.length];
-        for (int i = 0; i < newValues.length; i++) {
-            values[i] = getSession().getValueFactory().createValue(newValues[i]);
+        Value[] values = null;
+        if(newValues!=null){
+            values = new Value[newValues.length];
+            for (int i = 0; i < newValues.length; i++) {
+                values[i] = getSession().getValueFactory().createValue(newValues[i]);
+            }
         }
         this.itemData.setValues(values);
         this.itemData.setMultiple(true);
@@ -206,7 +212,7 @@ public int getType() throws RepositoryException {
         }
         else {
             return PropertyType.UNDEFINED;
-        }    
+        }
     }
 
     @Override
@@ -253,7 +259,7 @@ public boolean equals(Object obj) {
         }
         return false;
     }
-    
+
     // --- unsupported operations ---
     @Override
     public Node getNode() throws RepositoryException {
@@ -286,7 +292,7 @@ public boolean isMandatory() {
         public boolean isProtected() {
             return false;
         }
-        
+
         @Override
         public boolean isFullTextSearchable() {
             return false;
@@ -296,7 +302,7 @@ public boolean isFullTextSearchable() {
         public boolean isQueryOrderable() {
             return false;
         }
-        
+
         // --- unsupported operations ---
         @Override
         public Value[] getDefaultValues() {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services