-
Notifications
You must be signed in to change notification settings - Fork 565
JSON Patch uses org.springframework.core.convert.support.DefaultConversionService#getSharedInstance #2233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've got a tiny test that shows this problem in: https://github.com/buckett/spring-data-rest/tree/test-2233 |
Would you mind zooming out a bit and describe a user level problem this results in? |
Nevermind, your test case has all I need to think about this. |
Just to check I wasn't missing anything I did also create a test project showing the issue: https://github.com/buckett/json-patch-test |
We no pipe the Spring MVC ConversionService into the JSON Patch path binding. That usually is a FormattingConversionService at runtime and also supports the conversion of dates. The ConversionServices is configured into the BindContext(Factory) we use for binding. The context then exposes the EvaluationContext set up with it. Fixes #2233.
We no pipe the Spring MVC ConversionService into the JSON Patch path binding. That usually is a FormattingConversionService at runtime and also supports the conversion of dates. The ConversionServices is configured into the BindContext(Factory) we use for binding. The context then exposes the EvaluationContext set up with it. Fixes #2233.
I've just pushed a fix that included the test case you provided with the earlier project now succeeding. Would you mind trying the 4.0.3 snapshots ( |
Failing with the BOMI tried added
but this doesn't appear to help and I can't see any similar versions in the UI: https://repo.spring.io/ui/packages/gav:%2F%2Forg.springframework.data:spring-data-bom?name=spring-data-bom&type=packages Pulling in 4.0.x branchInstead I've tried pulling
I then attempted to patch the
it worked (HTTP 204) 👍 and double checking the person now has the new birthday. |
Yeez, I messed the version numbers up: it's got to be |
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 aorg.springframework.expression.spel.ExpressionState
and this uses aorg.springframework.expression.spel.support.SimpleEvaluationContext
which then ended up using aorg.springframework.expression.spel.support.StandardTypeConverter
, this in turn usesorg.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 theDefaultConversionService
.One solution might be to have
org.springframework.data.rest.webmvc.json.patch.SpelPath.TypedSpelPath#CONTEXT
setable at runtime and therefore allow aEvaluationContext
with a different conversion service to be used.The text was updated successfully, but these errors were encountered: