You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by pa...@apache.org on 2018/09/17 14:04:23 UTC

[sling-org-apache-sling-feature-io] branch master updated: Fix check type to not fail if class is null and more than a null value is present.

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

pauls pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-io.git


The following commit(s) were added to refs/heads/master by this push:
     new efc7703  Fix check type to not fail if class is null and more than a null value is present.
efc7703 is described below

commit efc770310c46b47ffbbd7d92e560cf835703966e
Author: Karl Pauls <ka...@gmail.com>
AuthorDate: Mon Sep 17 16:04:14 2018 +0200

    Fix check type to not fail if class is null and more than a null value is present.
---
 .../java/org/apache/sling/feature/io/json/JSONReaderBase.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
index 3d8405f..4602f2c 100644
--- a/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
+++ b/src/main/java/org/apache/sling/feature/io/json/JSONReaderBase.java
@@ -475,11 +475,12 @@ abstract class JSONReaderBase {
     protected void checkType(final String key, final Object val, Class<?>...types) throws IOException {
         boolean valid = false;
         for(final Class<?> c : types) {
-            if ( c == null && val == null) {
-                valid = true;
-                break;
-            }
-            if ( c.isInstance(val) ) {
+            if (c == null) {
+                if ( val == null) {
+                    valid = true;
+                    break;
+                }
+            } else if ( c.isInstance(val) ) {
                 valid = true;
                 break;
             }