cxf git commit: Add some NPE checks

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

cxf git commit: Add some NPE checks

Dennis Kieselhorst-2
Repository: cxf
Updated Branches:
  refs/heads/master 85e9a4780 -> 0ada3f2b8


Add some NPE checks


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/0ada3f2b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/0ada3f2b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/0ada3f2b

Branch: refs/heads/master
Commit: 0ada3f2b8ce9575ce27ed67b1eeecaf0be52943e
Parents: 85e9a47
Author: Dennis Kieselhorst <[hidden email]>
Authored: Fri Aug 11 10:36:20 2017 +0200
Committer: Dennis Kieselhorst <[hidden email]>
Committed: Fri Aug 11 10:36:20 2017 +0200

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/provider/AbstractJAXBProvider.java  |  2 +-
 .../java/org/apache/cxf/jaxrs/utils/InjectionUtils.java  |  4 ++--
 .../main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java | 11 +++++++----
 .../java/org/apache/cxf/jaxrs/utils/ResourceUtils.java   |  2 +-
 4 files changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/0ada3f2b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
index 9c6c612..eed4744 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
@@ -223,7 +223,7 @@ public abstract class AbstractJAXBProvider<T> extends AbstractConfigurableProvid
             }
             if (!schemaLocs.isEmpty()) {
                 this.setSchemaLocations(schemaLocs);
-                if (cris.size() == 0 && schema != null) {
+                if (cris.size() == 0 && schema != null && sv != null) {
                     SchemaValidation.SchemaValidationType type = sv.type();
                     if (type == SchemaValidation.SchemaValidationType.OUT) {
                         validateInputIfPossible = false;

http://git-wip-us.apache.org/repos/asf/cxf/blob/0ada3f2b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index bc05ca1..37897c8 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -929,12 +929,12 @@ public final class InjectionUtils {
             realGenericType = realType;
         } else {
             Type[] types = getActualTypes(genericType);
-            if (types.length == 0 || !(types[0] instanceof ParameterizedType)) {
+            if (types == null || types.length == 0 || !(types[0] instanceof ParameterizedType)) {
                 realType = getActualType(genericType);
                 realGenericType = realType;
             } else {
                 realType = getRawType(types[0]);
-                realGenericType = types[0] == realType ? realType : types[0];
+                realGenericType = types[0];
             }
         }
         Object theValues = null;

http://git-wip-us.apache.org/repos/asf/cxf/blob/0ada3f2b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
index b8a3020..87217bf 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
@@ -339,7 +339,8 @@ public final class JAXRSUtils {
                 if (cris.isEmpty()) {
                     firstCri = cri;
                     cris.put(cri, entry.getValue());
-                } else if (URITemplate.compareTemplates(firstCri.getURITemplate(), cri.getURITemplate()) == 0) {
+                } else if (firstCri != null
+                        && URITemplate.compareTemplates(firstCri.getURITemplate(), cri.getURITemplate()) == 0) {
                     cris.put(cri, entry.getValue());
                 } else {
                     break;
@@ -1550,8 +1551,10 @@ public final class JAXRSUtils {
                     String subTypeBeforePlus1 = splitMediaSubType(subType1, false);
                     String subTypeBeforePlus2 = splitMediaSubType(subType2, false);
                     nullPossible = subTypeBeforePlus1 == null || subTypeBeforePlus2 == null;
-                    isCompatible = subTypeBeforePlus1 == null && subTypeBeforePlus2.equals(subType1)
-                        || subTypeBeforePlus2 == null && subTypeBeforePlus1.equals(subType2);
+                    isCompatible = subTypeBeforePlus1 == null && subTypeBeforePlus2 != null
+                            && subTypeBeforePlus2.equals(subType1)
+                            || subTypeBeforePlus2 == null && subTypeBeforePlus1 != null
+                            && subTypeBeforePlus1.equals(subType2);
                     if (!isCompatible && !nullPossible) {
                         isCompatible = subTypeBeforePlus1.equalsIgnoreCase(subTypeBeforePlus2)
                             && (subType1.charAt(subType1.length() - 1) == '*'
@@ -1569,7 +1572,7 @@ public final class JAXRSUtils {
                     String subTypeBeforePlus1 = splitMediaSubType(subType1, false);
                     String subTypeBeforePlus2 = splitMediaSubType(subType2, false);
 
-                    isCompatible = subTypeBeforePlus1.equalsIgnoreCase(subTypeBeforePlus2)
+                    isCompatible = subTypeBeforePlus1 != null && subTypeBeforePlus1.equalsIgnoreCase(subTypeBeforePlus2)
                         && (subType1.charAt(subType1.length() - 1) == '*'
                             || subType2.charAt(subType2.length() - 1) == '*');
                 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/0ada3f2b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
index 36e1ced..5e93b5f 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
@@ -896,7 +896,7 @@ public final class ResourceUtils {
     public static Object createProviderInstance(Class<?> cls) {
         try {
             Constructor<?> c = ResourceUtils.findResourceConstructor(cls, false);
-            if (c.getParameterTypes().length == 0) {
+            if (c != null && c.getParameterTypes().length == 0) {
                 return c.newInstance();
             }
             return c;

Loading...