You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by kw...@apache.org on 2020/12/01 16:00:47 UTC

[jackrabbit-filevault] branch master updated: JCRVLT-482 fix ArrayIndexOutOfBoundsException when validating multivalue property with empty value array (#106)

This is an automated email from the ASF dual-hosted git repository.

kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jackrabbit-filevault.git


The following commit(s) were added to refs/heads/master by this push:
     new 2d62076  JCRVLT-482 fix ArrayIndexOutOfBoundsException when validating multivalue property with empty value array (#106)
2d62076 is described below

commit 2d6207684fbf78609463feccf0e1afec07ef6a70
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Tue Dec 1 17:00:37 2020 +0100

    JCRVLT-482 fix ArrayIndexOutOfBoundsException when validating multivalue property with empty value array (#106)
---
 .../spi/impl/nodetype/JcrNodeTypeMetaDataImpl.java         |  5 +++++
 .../spi/impl/nodetype/NodeTypeValidatorTest.java           | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/JcrNodeTypeMetaDataImpl.java b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/JcrNodeTypeMetaDataImpl.java
index b493d5c..80b9aef 100644
--- a/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/JcrNodeTypeMetaDataImpl.java
+++ b/vault-validation/src/main/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/JcrNodeTypeMetaDataImpl.java
@@ -521,6 +521,11 @@ public class JcrNodeTypeMetaDataImpl implements JcrNodeTypeMetaData {
                     + values.length + " values were passed!");
         }
 
+        if (values.length == 0) {
+            // unable to proceed when no value is present
+            return;
+        }
+
         Name qName;
         try {
             qName = namePathResolver.getQName(name);
diff --git a/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java b/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java
index e327d90..b24925c 100644
--- a/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java
+++ b/vault-validation/src/test/java/org/apache/jackrabbit/vault/validation/spi/impl/nodetype/NodeTypeValidatorTest.java
@@ -259,4 +259,18 @@ public class NodeTypeValidatorTest {
                 AnyValidationMessageMatcher.noValidationInCollection());
     }
 
+    @Test
+    public void testMultiValuePropertyWithEmptyValueArray() {
+        NodeContext nodeContext = new NodeContextImpl("/apps/test/node4", Paths.get("node4"), Paths.get(""));
+
+        Map<String, DocViewProperty> props = new HashMap<>();
+        DocViewProperty prop = new DocViewProperty("mvProperty", new String[0], true, PropertyType.STRING);
+        props.put("mvProperty", prop);
+        props.put(NameConstants.JCR_PRIMARYTYPE.toString(), new DocViewProperty(NameConstants.JCR_PRIMARYTYPE.toString(),
+                new String[] { JcrConstants.NT_UNSTRUCTURED }, false, PropertyType.STRING));
+        DocViewNode node = new DocViewNode("jcr:root", "jcr:root", null, props, null, JcrConstants.NT_UNSTRUCTURED);
+        Assert.assertThat(validator.validate(node, nodeContext, false),
+                AnyValidationMessageMatcher.noValidationInCollection());
+    }
+
 }