I'm new to Spring Native and GraalVM. I Have a Spring Boot application which fetches data from another service using RestTemplate. Using @RegisterReflectionForBinding I can successfuly fetch all queries, except for the following query and I can't figure out why it doesn't work.
I get the following error (logged):
17:01:48 [taskScheduler-6] [9b5785a1-4637-40d6-9d4d-bed86ce913e0] ERROR AquaControllerCommunicatorService - fetchPlacerRecommendations error: Type definition error: [collection type; class java.util.HashSet, contains [simple type, class java.lang.Object]]
Any help would be appreciated.
This is the method that does the fetching:
@RegisterReflectionForBinding({PlacerRecommendationsControllerRestDto.class, HashSet.class, Set.class, PlacerRecommendationsControllerRestDto.PlacerRecommendationControllerRestDto.class})
public Optional<PlacerRecommendations> fetchPlacerRecommendations() {
try {
log.debug("Fetching placer recommendations");
PlacerRecommendationsControllerRestDto placerRecommendationsControllerRestDto = restTemplate.getForObject("/api/v1/alg/placer", PlacerRecommendationsControllerRestDto.class);
if (placerRecommendationsControllerRestDto == null) {
return Optional.empty();
}
return Optional.of(placerRecommendationsControllerRestDto.toPlacerRecommendations());
} catch (Exception e) {
log.error("fetchPlacerRecommendations error: {}", e.getMessage());
return Optional.empty();
}
}
and this is the fetched dto:
@Data
@NoArgsConstructor
public class PlacerRecommendationsControllerRestDto {
private LocalDateTime recommendationTime;
private List<PlacerRecommendationsControllerRestDto.PlacerRecommendationControllerRestDto> placerRecommendations;
public PlacerRecommendations toPlacerRecommendations() {
return new PlacerRecommendations(
recommendationTime,
placerRecommendations.stream().map(PlacerRecommendationControllerRestDto::toPlacerRecommendation).toList()
);
}
@Data
@NoArgsConstructor
public static class PlacerRecommendationControllerRestDto {
private double latitude;
private double longitude;
private double altitude;
private Set<String> consumersCovered;
public PlacerRecommendation toPlacerRecommendation() {
return new PlacerRecommendation(
latitude,
longitude,
altitude,
new HashSet<>(consumersCovered)
);
}
}
}
Of course, it works just fine when I run it with the JVM.