Skip to content
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

Concurrency issue with ObjectMapper on RESTful http call #1855

Closed
ShawnTuatara opened this issue Nov 7, 2014 · 5 comments
Closed

Concurrency issue with ObjectMapper on RESTful http call #1855

ShawnTuatara opened this issue Nov 7, 2014 · 5 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@ShawnTuatara
Copy link
Contributor

I had originally asked about this issue on the Jackson side of things but thought it relevant to post this here as well.

FasterXML/jackson-databind#604

There was a comment on my original issue about why the canDeserialize() is being called instead of readValue() as well as if the ObjectMapper is being re-used. I am hoping that someone can take a look at how the spring-boot project is interacting with the ObjectMapper on the deserializing the json http request to see if there is any issues that would cause the problem I am having.

@philwebb
Copy link
Member

philwebb commented Nov 7, 2014

AFAICT AbstractJackson2HttpMessageConverter is the only class that calls ObjectMapper.canDeserialize and it uses a singleton ObjectMapper. Do you have a sample project that you can share? I especially interested in why DeserializerCache._findCachedDeserializer wouldn't get a hit and what JavaType is being requested.

/cc @rstoyanchev in case he has seen this in MVC before.

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Nov 7, 2014
@ShawnTuatara
Copy link
Contributor Author

I can't share this specific project but I think it might be related to the @RequestBody annotated parameter that I am using. Specifically it is:

    @RequestMapping(method = RequestMethod.POST)
    @ResponseStatus(HttpStatus.CREATED)
    public Map<String, List<EventId>> addEvent(@RequestBody Map<String, List<RestEventCreation>> wrappedEvents)

I read somewhere in the comments of the DeserializerCache that the Map deserializer doesn't get cached. I am going to try if I can convert that parameter type to be a class that encapsulates the Map definition that I have.

@ShawnTuatara
Copy link
Contributor Author

That resolved it. My method signature is now:

    @RequestMapping(method = RequestMethod.POST)
    @ResponseStatus(HttpStatus.CREATED)
    public Map<String, List<EventId>> addEvent(@RequestBody RestEventCreationWrapper restEventCreation, Integrator integrator)

@cowtowncoder any reason why Jackson doesn't allow caching of the Map type?

@cowtowncoder
Copy link

@ShawnTuatara I consider it a flaw, and will be fixing it for Jackson 2.4.4. Back in the day construction of Map deserializers was a much lighter operation, so assumption was that it'd be wasteful to cache. But that is definitely not the case any more. Thank you for reporting this!

@philwebb philwebb added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue labels Nov 10, 2014
@philwebb
Copy link
Member

@ShawnTuatara Thanks for the report. I'll close this one here and we'll wait for the Jackson 2.4.4 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants