spring boot @Cachable returning all fields of superclasses filled with null values

Viewed 382

we are facing a strange problem and I dont quit understand whats going on and hope someone else already had the same issue and has a clue what is going on.

We wrote a simple REST service making use of @Cachable:

@GetMapping(value = "/get/{" + PARAM_TENANT + "}/{" + PARAM_UID + "}")
@Cacheable(value = GET_ORDERS_BY_UID )
public GetOrdersResponseDto getOrdersByUid(@PathVariable final String tenant, @PathVariable final String uid) {
        ....
        return new GetOrdersResponseDto(createCacheKey(), orderResponseDtos);
}

GetOrdersResponseDto consists of several fields. Some contain instances of custom classes, some lists of them and other simple primitive values.

When the GetOrdersResponseDto response is served from the cache all fields of objects that are stored inside a list AND are located in the objects superclass are filled with null values.

We are using hazelcast as the cache implementation. And our cache config is very basic:

@Component
public class HazelcastConfig extends Config {

@Autowired
public HazelcastConfig(final ConfigClient configClient) {
    super();

    final GroupConfig groupConfig = getGroupConfig();
    final String name = configClient
        .getConfigPropertyValueOrThrow("public", "com.orderservice.hazelcast.group.name");
    groupConfig.setName("foogroup");

    final String password = configClient
        .getConfigPropertyValueOrThrow("public", "com.orderservice.hazelcast.group.password");
    groupConfig.setPassword(password);

The response class looks as follows:

public class GetOrdersResponseDto implements Serializable {

    private String cacheSerial;

    private List<OrderResponseDto> orderResponseDtos;

}

And the problems occur only for fields of OrderResponseDto that are part of the super class of OrderResponseDto.

I hope someone can give us an hint what's the cause for this strange behaviour.

Edit: I found out, that the problem only occurs for objects that are stored inside lists...

1 Answers
Related