Skip to content

Commit bb0437c

Browse files
committed
Correct names of isolated Json/ObjectMapper properties
Closes gh-48116
1 parent 62a1dd6 commit bb0437c

File tree

14 files changed

+38
-28
lines changed

14 files changed

+38
-28
lines changed

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/actuator/endpoints.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ TIP: See javadoc:org.springframework.boot.actuate.autoconfigure.endpoint.web.Cor
389389
When working with JSON, Jackson is used for serialization and deserialization.
390390
By default, an isolated javadoc:tools.jackson.databind.json.JsonMapper[] is used.
391391
This isolation means that it does not share the same configuration as the application's `JsonMapper` and it is not affected by `spring.jackson.*` properties.
392-
To disable this behavior and configure Actuator to use the application's `JsonMapper`, set configprop:management.endpoints.jackson.isolated-object-mapper[] to `false`.
392+
To disable this behavior and configure Actuator to use the application's `JsonMapper`, set configprop:management.endpoints.jackson.isolated-json-mapper[] to `false`.
393393
Alternatively, you can define your own javadoc:org.springframework.boot.actuate.endpoint.jackson.EndpointJsonMapper[] bean that produces a `JsonMapper` that meets your needs.
394394
Actuator will then use it for JSON processing.
395395

module/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jackson/Jackson2EndpointAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
public final class Jackson2EndpointAutoConfiguration {
4141

4242
@Bean
43-
@ConditionalOnBooleanProperty(name = "management.endpoints.jackson.isolated-object-mapper", matchIfMissing = true)
43+
@ConditionalOnBooleanProperty(name = "management.endpoints.jackson2.isolated-object-mapper", matchIfMissing = true)
4444
org.springframework.boot.actuate.endpoint.jackson.EndpointJackson2ObjectMapper jackson2EndpointJsonMapper() {
4545
ObjectMapper objectMapper = org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.json()
4646
.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,

module/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jackson/JacksonEndpointAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
public final class JacksonEndpointAutoConfiguration {
3838

3939
@Bean
40-
@ConditionalOnBooleanProperty(name = "management.endpoints.jackson.isolated-object-mapper", matchIfMissing = true)
40+
@ConditionalOnBooleanProperty(name = "management.endpoints.jackson.isolated-json-mapper", matchIfMissing = true)
4141
EndpointJsonMapper endpointJsonMapper() {
4242
JsonMapper jsonMapper = JsonMapper.builder()
4343
.changeDefaultPropertyInclusion(

module/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,21 @@
4444
}
4545
},
4646
{
47-
"name": "management.endpoints.jackson.isolated-object-mapper",
47+
"name": "management.endpoints.jackson.isolated-json-mapper",
4848
"type": "java.lang.Boolean",
49-
"description": "Whether to use an isolated object mapper to serialize endpoint JSON.",
49+
"description": "Whether to use an isolated JsonMapper to serialize endpoint JSON.",
5050
"defaultValue": true
5151
},
52+
{
53+
"name": "management.endpoints.jackson2.isolated-object-mapper",
54+
"type": "java.lang.Boolean",
55+
"description": "Whether to use an isolated object mapper to serialize endpoint JSON.",
56+
"defaultValue": true,
57+
"deprecation": {
58+
"reason": "Jackson 3 is preferred.",
59+
"since": "4.0.0"
60+
}
61+
},
5262
{
5363
"name": "management.endpoints.jmx.domain",
5464
"defaultValue": "org.springframework.boot"

module/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jackson/Jackson2EndpointAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void endpointObjectMapperWhenPropertyTrue() {
6464

6565
@Test
6666
void endpointObjectMapperWhenPropertyFalse() {
67-
this.runner.withPropertyValues("management.endpoints.jackson.isolated-object-mapper=false")
67+
this.runner.withPropertyValues("management.endpoints.jackson2.isolated-object-mapper=false")
6868
.run((context) -> assertThat(context)
6969
.doesNotHaveBean(org.springframework.boot.actuate.endpoint.jackson.EndpointJackson2ObjectMapper.class));
7070
}

module/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/jackson/JacksonEndpointAutoConfigurationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ void endpointJsonMapperWhenNoProperty() {
5050

5151
@Test
5252
void endpointJsonMapperWhenPropertyTrue() {
53-
this.runner.withPropertyValues("management.endpoints.jackson.isolated-object-mapper=true")
53+
this.runner.withPropertyValues("management.endpoints.jackson.isolated-json-mapper=true")
5454
.run((context) -> assertThat(context).hasSingleBean(EndpointJsonMapper.class));
5555
}
5656

5757
@Test
5858
void endpointJsonMapperWhenPropertyFalse() {
59-
this.runner.withPropertyValues("management.endpoints.jackson.isolated-object-mapper=false")
59+
this.runner.withPropertyValues("management.endpoints.jackson.isolated-json-mapper=false")
6060
.run((context) -> assertThat(context).doesNotHaveBean(EndpointJsonMapper.class));
6161
}
6262

smoke-test/spring-boot-smoke-test-actuator/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ management.endpoint.health.group.comp.show-details=always
3030

3131
management.endpoints.migrate-legacy-ids=true
3232

33-
management.endpoints.jackson.isolated-object-mapper=true
33+
management.endpoints.jackson.isolated-json-mapper=true
3434
spring.jackson.mapper.require-setters-for-getters=true
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package smoketest.actuator;
1818

1919
import org.junit.jupiter.api.Test;
20-
import tools.jackson.databind.ObjectMapper;
20+
import tools.jackson.databind.json.JsonMapper;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.boot.resttestclient.TestRestTemplate;
@@ -31,16 +31,16 @@
3131
import static org.assertj.core.api.Assertions.assertThat;
3232

3333
/**
34-
* Integration test for WebMVC actuator when using an isolated {@link ObjectMapper}.
34+
* Integration test for WebMVC actuator when not using an isolated {@link JsonMapper}.
3535
*
3636
* @author Phillip Webb
3737
*/
3838
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
39-
properties = { "management.endpoints.jackson.isolated-object-mapper=false",
39+
properties = { "management.endpoints.jackson.isolated-json-mapper=false",
4040
"spring.jackson.mapper.require-setters-for-getters=true" })
4141
@ContextConfiguration(loader = ApplicationStartupSpringBootContextLoader.class)
4242
@AutoConfigureTestRestTemplate
43-
class SampleActuatorApplicationIsolatedObjectMapperFalseTests {
43+
class SampleActuatorApplicationIsolatedJsonMapperFalseTests {
4444

4545
@Autowired
4646
private TestRestTemplate testRestTemplate;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package smoketest.actuator;
1818

1919
import org.junit.jupiter.api.Test;
20-
import tools.jackson.databind.ObjectMapper;
20+
import tools.jackson.databind.json.JsonMapper;
2121

2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.boot.resttestclient.TestRestTemplate;
@@ -31,16 +31,16 @@
3131
import static org.assertj.core.api.Assertions.assertThat;
3232

3333
/**
34-
* Integration test for WebMVC actuator when using an isolated {@link ObjectMapper}.
34+
* Integration test for WebMVC actuator when using an isolated {@link JsonMapper}.
3535
*
3636
* @author Phillip Webb
3737
*/
3838
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
39-
properties = { "management.endpoints.jackson.isolated-object-mapper=true",
39+
properties = { "management.endpoints.jackson.isolated-json-mapper=true",
4040
"spring.jackson.mapper.require-setters-for-getters=true" })
4141
@ContextConfiguration(loader = ApplicationStartupSpringBootContextLoader.class)
4242
@AutoConfigureTestRestTemplate
43-
class SampleActuatorApplicationIsolatedObjectMapperTrueTests {
43+
class SampleActuatorApplicationIsolatedJsonMapperTrueTests {
4444

4545
@Autowired
4646
private TestRestTemplate testRestTemplate;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
management.endpoints.web.exposure.include=*
2-
management.endpoints.jackson.isolated-object-mapper=true
2+
management.endpoints.jackson.isolated-json-mapper=true
33
spring.jackson2.visibility.field=any

0 commit comments

Comments
 (0)