Browse Source

Consistent support for new JsonMappingException wording in Jackson 2.9

Issue: SPR-16947
pull/1860/head
Juergen Hoeller 7 years ago
parent
commit
003d643adc
  1. 6
      spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java
  2. 7
      spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java

6
spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java

@ -54,7 +54,7 @@ import org.springframework.util.MimeType; @@ -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 { @@ -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" : "") +

7
spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 @@ -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" : "") +

Loading…
Cancel
Save