Skip to content

Commit 9a9032d

Browse files
authored
NPE due to concurrency bug #392: Make JsonSchemaRef more thread-safe; Removed unused members and constructor (#393)
1 parent afcd64e commit 9a9032d

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,12 @@
2828

2929
public class JsonSchemaRef {
3030

31-
private JsonSchema schema;
32-
private ValidationContext validationContext;
33-
private String refValue;
34-
35-
public JsonSchemaRef(ValidationContext validationContext, String refValue) {
36-
this.validationContext = validationContext;
37-
this.refValue = refValue;
38-
}
31+
private final JsonSchema schema;
3932

4033
public JsonSchemaRef(JsonSchema schema) {
4134
this.schema = schema;
4235
}
4336

44-
public void set(JsonSchema schema) {
45-
this.schema = schema;
46-
}
47-
4837
public Set<ValidationMessage> validate(JsonNode node, JsonNode rootNode, String at) {
4938
return schema.validate(node, rootNode, at);
5039
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ static JsonSchemaRef getRefSchema(JsonSchema parentSchema, ValidationContext val
9595
if (node != null) {
9696
JsonSchemaRef ref = validationContext.getReferenceParsingInProgress(refValueOriginal);
9797
if (ref == null) {
98-
ref = new JsonSchemaRef(validationContext, refValue);
98+
final JsonSchema schema = new JsonSchema(validationContext, refValue, parentSchema.getCurrentUri(), node, parentSchema);
99+
ref = new JsonSchemaRef(schema);
99100
validationContext.setReferenceParsingInProgress(refValueOriginal, ref);
100-
JsonSchema ret = new JsonSchema(validationContext, refValue, parentSchema.getCurrentUri(), node, parentSchema);
101-
ref.set(ret);
102101
}
103102
return ref;
104103
}

0 commit comments

Comments
 (0)