Consistent support for new JsonMappingException wording in Jackson 2.9

Issue: SPR-16947
This commit is contained in:
Juergen Hoeller 2018-06-17 21:42:20 +02:00
parent e4666c17ec
commit 003d643adc
2 changed files with 7 additions and 6 deletions

View File

@ -54,7 +54,7 @@ import org.springframework.util.MimeType;
* <li>{@link DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES} is disabled</li>
* </ul>
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
* <p>Compatible with Jackson 2.9 and higher, as of Spring 5.1.
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
@ -181,8 +181,8 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
return;
}
boolean debugLevel = (cause instanceof JsonMappingException &&
cause.getMessage().startsWith("Can not find"));
// Do not log warning for serializer not found (note: different message wording on Jackson 2.9)
boolean debugLevel = (cause instanceof JsonMappingException && cause.getMessage().startsWith("Cannot find"));
if (debugLevel ? logger.isDebugEnabled() : logger.isWarnEnabled()) {
String msg = "Failed to evaluate Jackson " + (type instanceof JavaType ? "de" : "") +

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -65,6 +65,7 @@ import org.springframework.util.TypeUtils;
* @author Juergen Hoeller
* @author Sebastien Deleuze
* @since 4.1
* @see MappingJackson2HttpMessageConverter
*/
public abstract class AbstractJackson2HttpMessageConverter extends AbstractGenericHttpMessageConverter<Object> {
@ -189,8 +190,8 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
return;
}
boolean debugLevel = (cause instanceof JsonMappingException &&
(cause.getMessage().startsWith("Can not find") || cause.getMessage().startsWith("Cannot find")));
// Do not log warning for serializer not found (note: different message wording on Jackson 2.9)
boolean debugLevel = (cause instanceof JsonMappingException && cause.getMessage().startsWith("Cannot find"));
if (debugLevel ? logger.isDebugEnabled() : logger.isWarnEnabled()) {
String msg = "Failed to evaluate Jackson " + (type instanceof JavaType ? "de" : "") +