You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spring-Boot Version: 1.5.9 (issue starts with version 1.5.3)
Description:
I want to get a list of endpoints exposed by actuator.
So I created a bean extending AbstractEndpoin. On invoke it returns a List.
Sample code:
@Component
public cluss LustEndpoints extends AbstractEndpoint<List<Endpoint>>{
private List<Endpoint> endpoints;
@Autowired
public ListEndPoints(List<Endpoint> endpoints) {
super("showendpoints", false, true);
this.endpoints = endpoints;
}
@Override
public List<Endpoint> invoke() {
return this.endpoints;
}
}
After startup and hit the /showendpoints of the server, I got a 500 response and the following message. I changed return object to only the EnvironmentEndpoint to make it clear:
"message": "Could not write JSON document: No serializer found for class org.springframework.core.convert.support.DefaultConversionService and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.boot.actuate.endpoint.EnvironmentEndpoint["resolver"]->org.springframework.boot.actuate.endpoint.EnvironmentEndpoint$PlaceholderSanitizingPropertyResolver["conversionService"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.core.convert.support.DefaultConversionService and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.boot.actuate.endpoint.EnvironmentEndpoint["resolver"]->org.springframework.boot.actuate.endpoint.EnvironmentEndpoint$PlaceholderSanitizingPropertyResolver["conversionService"])"
Compare source code of 1.5.2 and 1.5.3, I found difference between invoke() method implementations. I'm not sure if it's a bug or another way to map it.
Solution:
Without changing anything, suggested by the error message, I disabled SerializationFeature.FAIL_ON_EMPTY_BEANS by setting spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false in properties file.
The text was updated successfully, but these errors were encountered:
This is because in #8282, we introduced a getResolver() method on that class, and Jackson thinks it's a POJO attribute that should be serialized.
Your workaround works, but the bottom line is - you're not supposed to serialize Spring Boot internals as JSON objects - you should at least extract information out of them and use your own DTOs. If you don't, you expose your application to this kind of issue: any change on our side is likely to break your app.
Spring-Boot Version: 1.5.9 (issue starts with version 1.5.3)
Description:
I want to get a list of endpoints exposed by actuator.
So I created a bean extending AbstractEndpoin. On invoke it returns a List.
Sample code:
After startup and hit the /showendpoints of the server, I got a 500 response and the following message. I changed return object to only the EnvironmentEndpoint to make it clear:
Compare source code of 1.5.2 and 1.5.3, I found difference between invoke() method implementations. I'm not sure if it's a bug or another way to map it.
Solution:
Without changing anything, suggested by the error message, I disabled SerializationFeature.FAIL_ON_EMPTY_BEANS by setting
spring.jackson.serialization.FAIL_ON_EMPTY_BEANS=false
in properties file.The text was updated successfully, but these errors were encountered: