Skip to content

Add actuator specific ObjectMapper #12951

Closed
@vilhelm-persson-viper

Description

@vilhelm-persson-viper

When using a custom object mapper with MapperFeature.AUTO_DETECT_GETTERS disabled the detailed information for Health endpoint is not returned.

The status is returned as expected but not the detailed information.

From the code the getStatus method has Jackson annotation but the getDetails is lacking annotation.

Problem found using SpringBoot spring-boot-starter-parent version 2.0.1.RELEASE.

As a workaround and for verification of the problem is related to Jackson an MixIn class where created annotation for getStatus and getDetails and after that the information where displayed as expected.

mapper.addMixIn(Health.class, HealthMixIn.class);
public abstract class HealthMixIn {
  @JsonValue public abstract Object getStatus();
  @JsonValue public abstract Object getDetails();
}

How to repeat:

@Bean
@Primary
public ObjectMapper create() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.disable(MapperFeature.AUTO_DETECT_GETTERS)
    return mapper;
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions