mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Don't use global ObjectMapper when creating JacksonJsonpMapper
See gh-33438 Closes gh-33426
This commit is contained in:
parent
cf60c1c8a2
commit
3af30b0a11
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@ -49,8 +49,8 @@ class ElasticsearchClientConfigurations {
|
||||
static class JacksonJsonpMapperConfiguration {
|
||||
|
||||
@Bean
|
||||
JacksonJsonpMapper jacksonJsonpMapper(ObjectMapper objectMapper) {
|
||||
return new JacksonJsonpMapper(objectMapper);
|
||||
JacksonJsonpMapper jacksonJsonpMapper() {
|
||||
return new JacksonJsonpMapper();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 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.
|
||||
@ -23,6 +23,7 @@ import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
||||
import co.elastic.clients.json.jsonb.JsonbJsonpMapper;
|
||||
import co.elastic.clients.transport.ElasticsearchTransport;
|
||||
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.elasticsearch.client.RestClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -108,6 +109,16 @@ class ElasticsearchClientAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void jacksonJsonpMapperDoesNotUseGlobalObjectMapper() {
|
||||
this.contextRunner.withConfiguration(AutoConfigurations.of(JacksonAutoConfiguration.class))
|
||||
.withUserConfiguration(RestClientConfiguration.class).run((context) -> {
|
||||
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
|
||||
JacksonJsonpMapper jacksonJsonpMapper = context.getBean(JacksonJsonpMapper.class);
|
||||
assertThat(jacksonJsonpMapper.objectMapper()).isNotSameAs(objectMapper);
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class RestClientConfiguration {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user