Skip to content

Commit 228d117

Browse files
committed
Check nullable for null instead of catching the exception.
1 parent 3cd9c88 commit 228d117

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/main/java/com/networknt/schema/TypeValidator.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,9 @@ public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String
5656
return Collections.emptySet();
5757
}
5858
if (nodeType == JsonType.NULL) {
59-
try {
60-
if (this.getParentSchema().getSchemaNode().get("nullable").asBoolean()) {
61-
return Collections.emptySet();
62-
}
63-
} catch (Exception e) {
64-
logger.warn("Failed when trying to get nullable field.");
59+
JsonNode nullable = this.getParentSchema().getSchemaNode().get("nullable");
60+
if (nullable != null && nullable.asBoolean()) {
61+
return Collections.emptySet();
6562
}
6663
}
6764

0 commit comments

Comments
 (0)