Open
Description
Hi there,
I noticed that I cannot concurrently validate a payload against a schema even though all of my schemas were pre-loaded.
To reproduce, concurrently run the following code:
sl := gojsonschema.NewSchemaLoader()
sl.AddSchemas(...)
schema, err = sl.Compile(gojsonschema.NewReferenceLoader(...))
if err != nil {
panic(err)
}
docLoader := gojsonschema.NewBytesLoader(body)
result, err := schema.Validate(docLoader)
if err != nil {
panic(err)
}
if !result.Valid() {
for i, err := range result.Errors() {
fmt.Println(err)
}
}
I see two solutions here:
Add a mutex around the inner map, or create a Clone()
function so that if a user wants to concurrently validate things, they need to clone the schema loader first.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels