Skip to content

JsonSchemaFactory.getSchema not thread safe #891

@mpayne-coveo

Description

@mpayne-coveo

We have a service that uses the same caching mechanism/JsonSchemaFactory to load in JSON schemas, then validate against them as it handles requests in a multithreaded way. Lately, we've been seeing a lot of ConcurrentModificationExceptions when two requests are simultaneously handled and trying to retrieve schemas with the stack trace-

java.util.ConcurrentModificationException: null
	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1221)
	at com.networknt.schema.JsonSchemaFactory.findMetaSchemaForSchema(JsonSchemaFactory.java:350)
	at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:433)
	at com.networknt.schema.JsonSchemaFactory.getSchema(JsonSchemaFactory.java:462)

We're using version 1.0.87 of json-schema-validator. Let me know if you need further details

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions