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

Poor jackson parsing error message in MappingJackson2HttpMessageConverter [SPR-11603] #16226

Closed
spring-projects-issues opened this issue Mar 26, 2014 · 2 comments
Assignees
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Mar 26, 2014

Matteo Sumberaz opened SPR-11603 and commented

Hi all, while struggling with serialization bugs I've noticed that the debugging for SerializationContext.hasValueDeserializerFor

public boolean hasValueDeserializerFor(JavaType type, AtomicReference<Throwable> cause) {
        try {
            return _cache.hasValueDeserializerFor(this, _factory, type);
        } catch (JsonMappingException e) {
            if (cause != null) {
                cause.set(e);
            }
        } catch (RuntimeException e) {
            if (cause == null) { // earlier behavior
                throw e;
            }
            cause.set(e);
        }
        return false;
    }

is pretty bad if called by the ObjectMapper.canDeserialize method, that just pass null on the cause parameter

public boolean canDeserialize(JavaType type)
   {
       return createDeserializationContext(null,
               getDeserializationConfig()).hasValueDeserializerFor(type, null);
   }

and MappingJackson2HttpMessageConverter does exactly that

public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
		JavaType javaType = getJavaType(type, contextClass);
		return (this.objectMapper.canDeserialize(javaType) && canRead(mediaType));
	}

It is possible to improve this bubbling in some way the exceptions from the canDeserialize method?


Affects: 4.0 GA

Issue Links:

  • #16030 Log caught exception in MappingJackson2HttpMessageConverter
  • #15886 MappingJackson2(Http)MessageConverter should be more verbose in canRead/canWrite checks (on Jackson 2.3)
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 26, 2014

Juergen Hoeller commented

Looks like you were using 4.0 GA there, not 4.0.2... Since as of 4.0.1 and with a refined version in 4.0.2, we are passing an exception holder to Jackson, logging a resulting cause if exposed to us. You need to use a minimum of Jackson 2.3 and have your warn log level activated, then you should start seeing corresponding log entries.

As a consequence, I'm resolving this as fixed in 4.0.2 for the time being. Please reopen if anything is missing there.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Mar 26, 2014

Matteo Sumberaz commented

I'm very sorry, for some reason the spring-web is not alligned with the version of the rest of the spring parts in my projects, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants