-
Notifications
You must be signed in to change notification settings - Fork 340
NPE at JsonSchema.combineCurrentUriWithIds(JsonSchema.java:90) #347
Copy link
Copy link
Closed
Labels
Description
Here is my code:
def jsonSchema = this.getClass().getClassLoader().getResource("schema/test.json").text
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)
JsonSchema schema = factory.getSchema(jsonSchema)If the schema's $id field does not start with a scheme, it will throw a null pointer exception. Here is the full stack trace:
java.lang.NullPointerException
at com.networknt.schema.JsonSchema.combineCurrentUriWithIds(JsonSchema.java:90)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:72)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:58)
at com.networknt.schema.JsonSchema.<init>(JsonSchema.java:53)
at com.networknt.schema.JsonSchemaFactory.newJsonSchema(JsonSchemaFactory.java:254)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:282)
at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:290)
Here is my test schema:
{
"$id": "test",
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Test description",
"properties": {
"test": {
"description": "Sample property",
"examples": [
"hello",
"world"
],
"type": "string"
}
},
"required": [
"test"
],
"type": "object"
}It should throw a JsonSchemaException instead of a NullPointerException, but in combineCurrentUriWithIds, currentUri will be null and therefore currentUri.toString() on line 90 will throw a NPE.
Reactions are currently unavailable