Skip to content

Commit 4abbb8b

Browse files
committed
Sinplify condition event report
1 parent 39f6cdd commit 4abbb8b

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

core/src/main/java/org/everit/json/schema/ConditionalSchemaValidatingVisitor.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,17 @@ void visitIfSchema(Schema ifSchema) {
4242
void visitThenSchema(Schema thenSchema) {
4343
if (ifSchemaException == null) {
4444
ValidationException thenSchemaException = owner.getFailureOfSchema(thenSchema, subject);
45+
ValidationException failure = null;
4546
if (thenSchemaException != null) {
46-
ValidationException failure = new ValidationException(conditionalSchema,
47+
failure = new ValidationException(conditionalSchema,
4748
new StringBuilder(new StringBuilder("#")),
4849
"input is invalid against the \"then\" schema",
4950
Arrays.asList(thenSchemaException),
5051
"then",
5152
conditionalSchema.getSchemaLocation());
52-
5353
owner.failure(failure);
54-
owner.reportSchemaMatchEvent(thenSchema, failure);
55-
} else {
56-
owner.reportSchemaMatchEvent(thenSchema, null);
5754
}
55+
owner.reportSchemaMatchEvent(thenSchema, failure);
5856
} else {
5957
owner.reportSchemaMatchEvent(thenSchema, ifSchemaException);
6058
}
@@ -64,18 +62,18 @@ void visitThenSchema(Schema thenSchema) {
6462
void visitElseSchema(Schema elseSchema) {
6563
if (ifSchemaException != null) {
6664
ValidationException elseSchemaException = owner.getFailureOfSchema(elseSchema, subject);
65+
ValidationException failure = null;
6766
if (elseSchemaException != null) {
68-
ValidationException failure = new ValidationException(conditionalSchema,
67+
failure = new ValidationException(conditionalSchema,
6968
new StringBuilder(new StringBuilder("#")),
7069
"input is invalid against both the \"if\" and \"else\" schema",
7170
Arrays.asList(ifSchemaException, elseSchemaException),
7271
"else",
7372
conditionalSchema.getSchemaLocation());
7473
owner.failure(failure);
75-
owner.reportSchemaMatchEvent(elseSchema, failure);
76-
} else {
77-
owner.reportSchemaMatchEvent(elseSchema, null);
74+
7875
}
76+
owner.reportSchemaMatchEvent(elseSchema, failure);
7977
}
8078
}
8179

0 commit comments

Comments
 (0)