You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into an issue which I believe is a bug in how the ValidationProcessor is constructed from within the JsonSchemaFactory. Full context below:
I'm currently using a custom URIDownloader with the JsonSchemaFactory by attaching it to a scheme via a LoadingConfiguration. I also want to disable the caching aspect of the loader in the factory so that it retrieves from the URIDownloader as updates to the (same) schemas happen over time.
finalLoadingConfigurationBuilderloadingConfigBuilder = LoadingConfiguration.newBuilder();
loadingConfigBuilder.addScheme("http", myUriDownloader);
loadingConfigBuilder.setCacheSize(0); // Disables caching of schema loader in factorythis.schemaFactory = JsonSchemaFactory.newBuilder()
.setLoadingConfiguration(loadingConfigBuilder.freeze())
.freeze();
As updates happen to schemas, I can confirm that JsonSchemaFactory.getJsonSchema(...) indeed returns schema objects that reflect said updates (verified under debugger). However, when using said schema objects to do the validation on expectedly proper payloads, it fails as if the updates did not happen.
try {
JsonSchemajsonSchema = this.schemaFactory.getJsonSchema(schemaId); // <-- Shows the updated schema information when viewed under debuggerProcessingReportvalidationReport = jsonSchema.validate(paylaod);
if (!validationReport.isSuccess()) { // <-- This if statement evaluates to true (schema validation FAILED)
...
}
} catch (ProcessingExceptione) {
...
}
Specifically, the updates I'm testing with is by changing the type of the schema (from "string" to "integer," for instance):
When stepping through the code of JsonSchema.validate(...) under the debugger, it seems that the ValidationProcessor that is being used has its own cache, which ends up using the wrong validator type (which maps to the old schema type) to do the validation on the new schema type and payload. From looking at the JsonSchemaFactory code, it seems that the ValidationProcessor (which has its own cache) is constructed without accounting for the cache settings from LoadingConfiguration.
The text was updated successfully, but these errors were encountered:
MysticHLE
changed the title
Schema validation fails when LoadingConfiguration's caching is disabled when the schema is retrieved JsonSchemaFactory
Schema validation fails when LoadingConfiguration's caching is disabled when the schema is retrieved from JsonSchemaFactory
Dec 19, 2018
I'm running into an issue which I believe is a bug in how the
ValidationProcessor
is constructed from within theJsonSchemaFactory
. Full context below:I'm currently using a custom
URIDownloader
with theJsonSchemaFactory
by attaching it to a scheme via aLoadingConfiguration
. I also want to disable the caching aspect of the loader in the factory so that it retrieves from theURIDownloader
as updates to the (same) schemas happen over time.As updates happen to schemas, I can confirm that
JsonSchemaFactory.getJsonSchema(...)
indeed returns schema objects that reflect said updates (verified under debugger). However, when using said schema objects to do the validation on expectedly proper payloads, it fails as if the updates did not happen.Specifically, the updates I'm testing with is by changing the type of the schema (from "string" to "integer," for instance):
From:
To:
When stepping through the code of
JsonSchema.validate(...)
under the debugger, it seems that theValidationProcessor
that is being used has its own cache, which ends up using the wrong validator type (which maps to the old schema type) to do the validation on the new schema type and payload. From looking at theJsonSchemaFactory
code, it seems that theValidationProcessor
(which has its own cache) is constructed without accounting for the cache settings fromLoadingConfiguration
.The text was updated successfully, but these errors were encountered: