bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject [31/50] bval git commit: avoid NPE on xml ctors
Date Tue, 16 Oct 2018 17:31:35 GMT
avoid NPE on xml ctors


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

Branch: refs/heads/bv2
Commit: e5e22d3e650e4960657e4fdbdd10f61691b8a9a0
Parents: e243ee9
Author: Matt Benson <mbenson@apache.org>
Authored: Wed Apr 18 17:16:42 2018 -0500
Committer: Matt Benson <mbenson@apache.org>
Committed: Tue Oct 16 12:28:20 2018 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/bval/jsr/xml/MappingValidator.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bval/blob/e5e22d3e/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java
----------------------------------------------------------------------
diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java
index f3b017e..9b9f4a4 100644
--- a/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java
+++ b/bval-jsr/src/main/java/org/apache/bval/jsr/xml/MappingValidator.java
@@ -166,10 +166,11 @@ public class MappingValidator {
             final Constructor<?> dc = Reflection.getDeclaredConstructor(t, parameterTypes);
             Exceptions.raiseIf(dc == null, ValidationException::new, "Unknown %s constructor
%s", t, result);
 
-            final ForConstructor<?> metaCtor = new Meta.ForConstructor<>(dc);
-            constraints(metaCtor, ctor.getReturnValue().getConstraint());
-            containerElements(metaCtor, ctor.getReturnValue().getContainerElementType());
-
+            Optional.of(ctor).map(ConstructorType::getReturnValue).ifPresent(rv -> {
+                final ForConstructor<?> metaCtor = new Meta.ForConstructor<>(dc);
+                constraints(metaCtor, rv.getConstraint());
+                containerElements(metaCtor, rv.getContainerElementType());
+            });
             final Parameter[] params = dc.getParameters();
 
             IntStream.range(0, parameterTypes.length).forEach(n -> {


Mime
View raw message