Optional orElseGet method returns ArrayList rather then Set

The following code throws: ClassCastException: java.util.ArrayList cannot be cast to java.util.Set` Set<Atuacao> a = atuacoes.findByEmailAndSistemaAndPerfil(email.toUpperCase(),idSistema) .orElseGet(TreeSet::new); The method findByEmailAndSistemaAndPerfil returns correctly two items of type Atuacao in a Set, in an Optional. Why the orElseGet method is returning an ArrayList? I’m using Spring Data Jpa. Added: Method findByEmailAndSistemaAndPerfil definition: public Optional<Set<Atuacao>> findByEmailAndSistemaAndPerfil( @Param(“email”) String email,…

Details