I have a pretty simple use-case in spring boot (currently 2.7, we do have plans to upgrade down the line) around a DAO:
@Repository
public class Dao {
private final DbMapper mapper;
@Autowired
public Dao(DbMapper mapper) {
this.mapper = mapper;
}
@SafeVarargs
public final Flux<Dto> getAll(Consumer<Dto>... filters) {
return Flux.fromIterable(LibraryQueryBuilder. builder()
.filters(filters)
.build()
.execute(mapper)
.getAll());
}
}
This is perfectly valid java, but during runtime I see that mapper is null. During my investigation, I ran into: Spring: Accessing field from final method returning null which lead me to Spring-Boot 2+ forces CGLIB proxy even with proxyTargetClass = false and GitHub Issue 12194 which were both disappointing responses in the context of this issue.
Considering @SafeVarargs is a Java core language feature to stop compiler warnings and requires the method to be final, and I don't want to see warnings all over my usage code when I'm using the varags safely is there any way to get @SafeVarargs to play nice with spring boot?