Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 12c77db

Browse files
committedNov 10, 2022
Support isolated actuator ObjectMapper
Closes gh-20291
2 parents 72cbb8a + 82254e3 commit 12c77db

File tree

59 files changed

+1149
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1149
-59
lines changed
 

‎spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.fasterxml.jackson.annotation.JsonInclude.Include;
2828
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
2929

30+
import org.springframework.boot.actuate.endpoint.OperationResponseBody;
3031
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
3132
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
3233
import org.springframework.boot.autoconfigure.condition.ConditionEvaluationReport;
@@ -81,7 +82,7 @@ private ConfigurableApplicationContext getConfigurableParent(ConfigurableApplica
8182
/**
8283
* A description of an application's condition evaluation.
8384
*/
84-
public static final class ConditionsDescriptor {
85+
public static final class ConditionsDescriptor implements OperationResponseBody {
8586

8687
private final Map<String, ContextConditionsDescriptor> contexts;
8788

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2012-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.endpoint.jackson;
18+
19+
import com.fasterxml.jackson.databind.ObjectMapper;
20+
21+
import org.springframework.boot.actuate.endpoint.jackson.EndpointObjectMapper;
22+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
23+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
25+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
26+
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
27+
import org.springframework.context.annotation.Bean;
28+
import org.springframework.context.annotation.Configuration;
29+
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
30+
31+
/**
32+
* {@link EnableAutoConfiguration Auto-configuration} for Endpoint Jackson support.
33+
*
34+
* @author Phillip Webb
35+
* @since 3.0.0
36+
*/
37+
@Configuration(proxyBeanMethods = false)
38+
@AutoConfigureAfter(JacksonAutoConfiguration.class)
39+
public class JacksonEndpointAutoConfiguration {
40+
41+
@Bean
42+
@ConditionalOnProperty(name = "management.endpoints.jackson.isolated-object-mapper", matchIfMissing = true)
43+
@ConditionalOnClass({ ObjectMapper.class, Jackson2ObjectMapperBuilder.class })
44+
public EndpointObjectMapper endpointObjectMapper() {
45+
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
46+
return () -> objectMapper;
47+
}
48+
49+
}

0 commit comments

Comments
 (0)
Please sign in to comment.