Skip to content

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

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

Closed
spring-projects-issues opened this issue Mar 26, 2014 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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:

@spring-projects-issues
Copy link
Collaborator Author

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

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
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants