Skip to content

Commit afd507e

Browse files
committed
Hacking.
1 parent 79a816e commit afd507e

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<xmlbeam>1.4.26</xmlbeam>
3535
<java-module-name>spring.data.commons</java-module-name>
3636
<kotlin.api.target>1.8</kotlin.api.target>
37+
<spring-hateoas>3.0.0-GH-2357-SNAPSHOT</spring-hateoas>
3738
</properties>
3839

3940
<dependencies>

src/main/java/org/springframework/data/web/ProjectingJacksonHttpMessageConverter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import tools.jackson.core.JsonGenerator;
1919
import tools.jackson.databind.ObjectMapper;
2020
import tools.jackson.databind.ObjectReader;
21+
import tools.jackson.databind.json.JsonMapper;
2122

2223
import java.io.IOException;
2324
import java.io.InputStream;
@@ -30,7 +31,6 @@
3031
import java.util.concurrent.ConcurrentHashMap;
3132

3233
import org.jspecify.annotations.Nullable;
33-
3434
import org.springframework.beans.BeansException;
3535
import org.springframework.beans.factory.BeanClassLoaderAware;
3636
import org.springframework.beans.factory.BeanFactory;
@@ -40,7 +40,6 @@
4040
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
4141
import org.springframework.http.HttpInputMessage;
4242
import org.springframework.http.MediaType;
43-
import org.springframework.http.converter.HttpMessageConverter;
4443
import org.springframework.http.converter.HttpMessageNotReadableException;
4544
import org.springframework.http.converter.json.JacksonJsonHttpMessageConverter;
4645
import org.springframework.util.Assert;
@@ -72,15 +71,15 @@ public class ProjectingJacksonHttpMessageConverter extends JacksonJsonHttpMessag
7271
* Creates a new {@link ProjectingJacksonHttpMessageConverter} using a default {@link ObjectMapper}.
7372
*/
7473
public ProjectingJacksonHttpMessageConverter() {
75-
this.projectionFactory = initProjectionFactory(getObjectMapper());
74+
this.projectionFactory = initProjectionFactory(getMapper());
7675
}
7776

7877
/**
7978
* Creates a new {@link ProjectingJacksonHttpMessageConverter} for the given {@link ObjectMapper}.
8079
*
8180
* @param mapper must not be {@literal null}.
8281
*/
83-
public ProjectingJacksonHttpMessageConverter(ObjectMapper mapper) {
82+
public ProjectingJacksonHttpMessageConverter(JsonMapper mapper) {
8483

8584
super(mapper);
8685

src/main/java/org/springframework/data/web/config/SpringDataJackson3Configuration.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@
2828
import org.jspecify.annotations.Nullable;
2929
import org.slf4j.Logger;
3030
import org.slf4j.LoggerFactory;
31-
3231
import org.springframework.beans.factory.annotation.Autowired;
3332
import org.springframework.context.annotation.Bean;
3433
import org.springframework.data.domain.Page;
3534
import org.springframework.data.domain.PageImpl;
36-
import org.springframework.data.geo.GeoModule;
35+
import org.springframework.data.geo.GeoJacksonModule;
3736
import org.springframework.data.web.PagedModel;
3837
import org.springframework.data.web.config.EnableSpringDataWebSupport.PageSerializationMode;
3938
import org.springframework.util.ClassUtils;
@@ -47,12 +46,11 @@
4746
*/
4847
public class SpringDataJackson3Configuration implements SpringDataJackson3Modules {
4948

50-
@Nullable
51-
@Autowired(required = false) SpringDataWebSettings settings;
49+
@Nullable @Autowired(required = false) SpringDataWebSettings settings;
5250

5351
@Bean
54-
public GeoModule jackson3GeoModule() {
55-
return new GeoModule();
52+
public GeoJacksonModule jackson3GeoModule() {
53+
return new GeoJacksonModule();
5654
}
5755

5856
@Bean

src/main/java/org/springframework/data/web/config/SpringDataWebConfiguration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
*/
1616
package org.springframework.data.web.config;
1717

18+
import tools.jackson.databind.json.JsonMapper;
19+
1820
import java.util.ArrayList;
1921
import java.util.List;
2022

2123
import org.jspecify.annotations.Nullable;
22-
2324
import org.springframework.beans.factory.BeanClassLoaderAware;
2425
import org.springframework.beans.factory.ObjectFactory;
2526
import org.springframework.beans.factory.annotation.Qualifier;
@@ -47,11 +48,10 @@
4748
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
4849
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
4950

50-
5151
/**
5252
* Configuration class to register {@link PageableHandlerMethodArgumentResolver},
53-
* {@link SortHandlerMethodArgumentResolver}, {@link OffsetScrollPositionHandlerMethodArgumentResolver}
54-
* and {@link DomainClassConverter}.
53+
* {@link SortHandlerMethodArgumentResolver}, {@link OffsetScrollPositionHandlerMethodArgumentResolver} and
54+
* {@link DomainClassConverter}.
5555
*
5656
* @since 1.6
5757
* @author Oliver Gierke
@@ -91,7 +91,8 @@ public SpringDataWebConfiguration(ApplicationContext context,
9191
this.sortResolverCustomizer = Lazy.of( //
9292
() -> context.getBeanProvider(SortHandlerMethodArgumentResolverCustomizer.class).getIfAvailable());
9393
this.offsetResolverCustomizer = Lazy.of( //
94-
() -> context.getBeanProvider(OffsetScrollPositionHandlerMethodArgumentResolverCustomizer.class).getIfAvailable());
94+
() -> context.getBeanProvider(OffsetScrollPositionHandlerMethodArgumentResolverCustomizer.class)
95+
.getIfAvailable());
9596
}
9697

9798
@Override
@@ -170,8 +171,7 @@ public void configureMessageConverters(List<HttpMessageConverter<?>> converters)
170171

171172
if (ClassUtils.isPresent("tools.jackson.databind.ObjectReader", context.getClassLoader())) {
172173

173-
tools.jackson.databind.ObjectMapper mapper = context.getBeanProvider(tools.jackson.databind.ObjectMapper.class)
174-
.getIfUnique(tools.jackson.databind.ObjectMapper::new);
174+
JsonMapper mapper = context.getBeanProvider(JsonMapper.class).getIfUnique(JsonMapper::new);
175175

176176
ProjectingJacksonHttpMessageConverter converter = new ProjectingJacksonHttpMessageConverter(mapper);
177177
converter.setBeanFactory(context);

src/test/java/org/springframework/data/web/config/SpringDataWebConfigurationIntegrationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
package org.springframework.data.web.config;
1717

1818
import static org.assertj.core.api.Assertions.*;
19+
import static org.mockito.ArgumentMatchers.*;
1920
import static org.mockito.Mockito.*;
2021

2122
import tools.jackson.databind.ObjectMapper;
23+
import tools.jackson.databind.json.JsonMapper;
2224

2325
import java.util.ArrayList;
2426
import java.util.Arrays;
@@ -27,7 +29,6 @@
2729

2830
import org.junit.jupiter.api.Test;
2931
import org.mockito.ArgumentCaptor;
30-
3132
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
3233
import org.springframework.context.annotation.Bean;
3334
import org.springframework.context.annotation.Configuration;
@@ -38,7 +39,6 @@
3839
import org.springframework.http.converter.HttpMessageConverters;
3940
import org.springframework.instrument.classloading.ShadowingClassLoader;
4041
import org.springframework.util.ReflectionUtils;
41-
4242
import org.xmlbeam.XBProjector;
4343

4444
import com.jayway.jsonpath.DocumentContext;
@@ -114,7 +114,7 @@ void usesCustomObjectMapper() {
114114

115115
assertThat(captor.getAllValues()).anySatisfy(converter -> {
116116
assertThat(converter).isInstanceOfSatisfying(ProjectingJacksonHttpMessageConverter.class, __ -> {
117-
assertThat(__.getObjectMapper()).isSameAs(SomeConfiguration.MAPPER);
117+
assertThat(__.getMapper()).isSameAs(SomeConfiguration.MAPPER);
118118
});
119119
});
120120
}, SomeConfiguration.class);
@@ -152,10 +152,10 @@ private static Class<?> loadWithout(Class<?> configurationClass, Class<?>... typ
152152
@Configuration
153153
static class SomeConfiguration {
154154

155-
static ObjectMapper MAPPER = new ObjectMapper();
155+
static JsonMapper MAPPER = new JsonMapper();
156156

157157
@Bean
158-
ObjectMapper mapper() {
158+
JsonMapper mapper() {
159159
return MAPPER;
160160
}
161161
}

0 commit comments

Comments
 (0)