Browse Source

Compatibility with Jackson 2.12 (tested against 2.12.0-rc1)

Closes gh-25907
pull/25647/head
Juergen Hoeller 4 years ago
parent
commit
a6e48811c0
  1. 2
      spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java
  2. 2
      spring-messaging/src/main/java/org/springframework/messaging/converter/MappingJackson2MessageConverter.java
  3. 4
      spring-web/src/main/java/org/springframework/http/converter/cbor/MappingJackson2CborHttpMessageConverter.java
  4. 2
      spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java
  5. 6
      spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
  6. 4
      spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java
  7. 4
      spring-web/src/main/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverter.java
  8. 4
      spring-web/src/main/java/org/springframework/http/converter/smile/MappingJackson2SmileHttpMessageConverter.java
  9. 4
      spring-web/src/main/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter.java
  10. 14
      spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java
  11. 2
      spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java
  12. 9
      spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java
  13. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/AbstractJackson2View.java
  14. 2
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java
  15. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java

2
spring-jms/src/main/java/org/springframework/jms/support/converter/MappingJackson2MessageConverter.java

@ -55,7 +55,7 @@ import org.springframework.util.ClassUtils; @@ -55,7 +55,7 @@ import org.springframework.util.ClassUtils;
* <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 to 2.12, as of Spring 5.3.
*
* @author Mark Pollack
* @author Dave Syer

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

@ -52,7 +52,7 @@ import org.springframework.util.MimeType; @@ -52,7 +52,7 @@ import org.springframework.util.MimeType;
* <li>{@link DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES} is disabled</li>
* </ul>
*
* <p>Compatible with Jackson 2.9 and higher, as of Spring 5.1.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller

4
spring-web/src/main/java/org/springframework/http/converter/cbor/MappingJackson2CborHttpMessageConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -37,7 +37,7 @@ import org.springframework.util.Assert; @@ -37,7 +37,7 @@ import org.springframework.util.Assert;
* <p>The default constructor uses the default configuration provided by
* {@link Jackson2ObjectMapperBuilder}.
*
* <p>Compatible with Jackson 2.9 and higher.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Sebastien Deleuze
* @since 5.0

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

@ -61,7 +61,7 @@ import org.springframework.util.TypeUtils; @@ -61,7 +61,7 @@ import org.springframework.util.TypeUtils;
* Abstract base class for Jackson based and content type independent
* {@link HttpMessageConverter} implementations.
*
* <p>Compatible with Jackson 2.9 and higher, as of Spring 5.0.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Arjen Poutsma
* @author Keith Donald

6
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

@ -92,7 +92,7 @@ import org.springframework.util.xml.StaxUtils; @@ -92,7 +92,7 @@ import org.springframework.util.xml.StaxUtils;
* support for Kotlin classes and data classes</li>
* </ul>
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Sebastien Deleuze
* @author Juergen Hoeller
@ -649,8 +649,8 @@ public class Jackson2ObjectMapperBuilder { @@ -649,8 +649,8 @@ public class Jackson2ObjectMapperBuilder {
* An option to apply additional customizations directly to the
* {@code ObjectMapper} instances at the end, after all other config
* properties of the builder have been applied.
* @param configurer a configurer to apply; if invoked multiple times, all
* configurers are applied in the same order.
* @param configurer a configurer to apply. If several configurers are
* registered, they will get applied in their registration order.
* @since 5.3
*/
public Jackson2ObjectMapperBuilder postConfigurer(Consumer<ObjectMapper> configurer) {

4
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -135,7 +135,7 @@ import org.springframework.lang.Nullable; @@ -135,7 +135,7 @@ import org.springframework.lang.Nullable;
* &lt;/bean
* </pre>
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author <a href="mailto:dmitry.katsubo@gmail.com">Dmitry Katsubo</a>
* @author Rossen Stoyanchev

4
spring-web/src/main/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -36,7 +36,7 @@ import org.springframework.lang.Nullable; @@ -36,7 +36,7 @@ import org.springframework.lang.Nullable;
*
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
*
* <p>Compatible with Jackson 2.9 and higher, as of Spring 5.0.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Arjen Poutsma
* @author Keith Donald

4
spring-web/src/main/java/org/springframework/http/converter/smile/MappingJackson2SmileHttpMessageConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 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.
@ -35,7 +35,7 @@ import org.springframework.util.Assert; @@ -35,7 +35,7 @@ import org.springframework.util.Assert;
*
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
*
* <p>Compatible with Jackson 2.9 and higher.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Sebastien Deleuze
* @since 5.0

4
spring-web/src/main/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -37,7 +37,7 @@ import org.springframework.util.Assert; @@ -37,7 +37,7 @@ import org.springframework.util.Assert;
*
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
*
* <p>Compatible with Jackson 2.9 and higher, as of Spring 5.0.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Sebastien Deleuze
* @since 4.1

14
spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java

@ -354,7 +354,7 @@ class Jackson2ObjectMapperBuilderTests { @@ -354,7 +354,7 @@ class Jackson2ObjectMapperBuilderTests {
@Test
void propertyNamingStrategy() {
PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy();
PropertyNamingStrategy strategy = new PropertyNamingStrategy.SnakeCaseStrategy();
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().propertyNamingStrategy(strategy).build();
assertThat(objectMapper.getSerializationConfig().getPropertyNamingStrategy()).isSameAs(strategy);
assertThat(objectMapper.getDeserializationConfig().getPropertyNamingStrategy()).isSameAs(strategy);
@ -430,9 +430,8 @@ class Jackson2ObjectMapperBuilderTests { @@ -430,9 +430,8 @@ class Jackson2ObjectMapperBuilderTests {
assertThat(output).doesNotContain("value2");
}
@Test // gh-23017
@Test // gh-23017
void postConfigurer() {
JacksonAnnotationIntrospector introspector1 = new JacksonAnnotationIntrospector();
JacksonAnnotationIntrospector introspector2 = new JacksonAnnotationIntrospector();
@ -456,7 +455,7 @@ class Jackson2ObjectMapperBuilderTests { @@ -456,7 +455,7 @@ class Jackson2ObjectMapperBuilderTests {
JsonSerializer<Number> serializer2 = new NumberSerializer(Integer.class);
Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json()
.modules(new ArrayList<>()) // Disable well-known modules detection
.modules(new ArrayList<>()) // Disable well-known modules detection
.serializers(serializer1)
.serializersByType(Collections.singletonMap(Boolean.class, serializer2))
.deserializersByType(deserializerMap)
@ -564,7 +563,6 @@ class Jackson2ObjectMapperBuilderTests { @@ -564,7 +563,6 @@ class Jackson2ObjectMapperBuilderTests {
assertThat(objectMapper.getFactory().getClass()).isEqualTo(SmileFactory.class);
}
@Test
void visibility() throws JsonProcessingException {
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
@ -578,6 +576,7 @@ class Jackson2ObjectMapperBuilderTests { @@ -578,6 +576,7 @@ class Jackson2ObjectMapperBuilderTests {
assertThat(json).doesNotContain("property3");
}
static class CustomIntegerModule extends Module {
@Override
@ -664,6 +663,7 @@ class Jackson2ObjectMapperBuilderTests { @@ -664,6 +663,7 @@ class Jackson2ObjectMapperBuilderTests {
}
}
static class JacksonVisibilityBean {
@SuppressWarnings("unused")
@ -674,9 +674,9 @@ class Jackson2ObjectMapperBuilderTests { @@ -674,9 +674,9 @@ class Jackson2ObjectMapperBuilderTests {
public String getProperty3() {
return null;
}
}
static class OffsetDateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {
private static final String CURRENT_ZONE_OFFSET = OffsetDateTime.now().getOffset().toString();
@ -697,6 +697,7 @@ class Jackson2ObjectMapperBuilderTests { @@ -697,6 +697,7 @@ class Jackson2ObjectMapperBuilderTests {
}
}
@JsonDeserialize
static class DemoPojo {
@ -709,7 +710,6 @@ class Jackson2ObjectMapperBuilderTests { @@ -709,7 +710,6 @@ class Jackson2ObjectMapperBuilderTests {
public void setOffsetDateTime(OffsetDateTime offsetDateTime) {
this.offsetDateTime = offsetDateTime;
}
}
@SuppressWarnings("serial")

2
spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java

@ -261,7 +261,7 @@ public class Jackson2ObjectMapperFactoryBeanTests { @@ -261,7 +261,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
@Test
public void propertyNamingStrategy() {
PropertyNamingStrategy strategy = new PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy();
PropertyNamingStrategy strategy = new PropertyNamingStrategy.SnakeCaseStrategy();
this.factory.setPropertyNamingStrategy(strategy);
this.factory.afterPropertiesSet();

9
spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@ -46,7 +46,6 @@ import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; @@ -46,7 +46,6 @@ import com.fasterxml.jackson.databind.jsontype.TypeDeserializer;
import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder;
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -202,11 +201,6 @@ public class SpringHandlerInstantiatorTests { @@ -202,11 +201,6 @@ public class SpringHandlerInstantiatorTests {
return JsonTypeInfo.Id.CUSTOM;
}
// Only needed when compiling against Jackson 2.7; gone in 2.8
public JavaType typeFromId(String s) {
return TypeFactory.defaultInstance().constructFromCanonical(s);
}
@Override
public String idFromValue(Object value) {
isAutowiredFiledInitialized = (this.capitalizer != null);
@ -227,7 +221,6 @@ public class SpringHandlerInstantiatorTests { @@ -227,7 +221,6 @@ public class SpringHandlerInstantiatorTests {
return null;
}
// New in Jackson 2.7
@Override
public String getDescForKnownTypeIds() {
return null;

4
spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/AbstractJackson2View.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -41,7 +41,7 @@ import org.springframework.web.servlet.view.AbstractView; @@ -41,7 +41,7 @@ import org.springframework.web.servlet.view.AbstractView;
* Abstract base class for Jackson based and content type independent
* {@link AbstractView} implementations.
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Jeremy Grelle
* @author Arjen Poutsma

2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java

@ -42,7 +42,7 @@ import org.springframework.web.servlet.View; @@ -42,7 +42,7 @@ import org.springframework.web.servlet.View;
*
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Jeremy Grelle
* @author Arjen Poutsma

4
spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 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.
@ -38,7 +38,7 @@ import org.springframework.web.servlet.view.json.AbstractJackson2View; @@ -38,7 +38,7 @@ import org.springframework.web.servlet.view.json.AbstractJackson2View;
*
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
*
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
* <p>Compatible with Jackson 2.9 to 2.12, as of Spring 5.3.
*
* @author Sebastien Deleuze
* @since 4.1

Loading…
Cancel
Save