Skip to content

JSON Patch uses org.springframework.core.convert.support.DefaultConversionService#getSharedInstance #2233

@buckett

Description

@buckett

When a JSON patch request is made the paths are parsed and converted into org.springframework.data.rest.webmvc.json.patch.SpelPath when values are then replaced the SpEL paths are then evaluated using a org.springframework.expression.spel.ExpressionState and this uses a org.springframework.expression.spel.support.SimpleEvaluationContext which then ended up using a org.springframework.expression.spel.support.StandardTypeConverter, this in turn uses org.springframework.core.convert.support.DefaultConversionService#getSharedInstance for it's conversion service.

This works for simple cases (Strings and Ints), but the DefaultConversionService doesn't have complete support for Java 8 date and time classes and the JavaDoc on the method recommends that the service should only be used as a fallback.

There doesn't seem to be a way to override the ConversionService that is used when evaluating SpEL paths in JSON Patch files and it doesn't seem to be possible to add additional converters to the DefaultConversionService.

One solution might be to have org.springframework.data.rest.webmvc.json.patch.SpelPath.TypedSpelPath#CONTEXT setable at runtime and therefore allow a EvaluationContext with a different conversion service to be used.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions