Open nickbreen opened 4 weeks ago
Thanks. I was able to reproduce this with the follow class:
package typearginfer;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
public class Issue6762 {
void method(ResultSet rs) throws SQLException {
final IntSet roleIds = Optional.ofNullable(rs.getString("role_ids")).map(
rids -> Arrays.stream(rids.split(",")).map(Integer::parseInt)
.collect(Collectors.collectingAndThen(Collectors.toSet(), IntArraySet::new)))
.orElse(new IntArraySet());
}
static class IntArraySet extends IntSet {
IntArraySet() {}
IntArraySet(Set<Integer> i) {}
}
static class IntSet implements Set<Integer> {
@Override
public int size() {
return 0;
}
@Override
public boolean isEmpty() {
return false;
}
@Override
public boolean contains(Object o) {
return false;
}
@Override
public Iterator<Integer> iterator() {
return null;
}
@Override
public Object[] toArray() {
return new Object[0];
}
@Override
public <T> T[] toArray(T[] a) {
return null;
}
@Override
public boolean add(Integer integer) {
return false;
}
@Override
public boolean remove(Object o) {
return false;
}
@Override
public boolean containsAll(Collection<?> c) {
return false;
}
@Override
public boolean addAll(Collection<? extends Integer> c) {
return false;
}
@Override
public boolean retainAll(Collection<?> c) {
return false;
}
@Override
public boolean removeAll(Collection<?> c) {
return false;
}
@Override
public void clear() {}
}
}
Note,
rs
is ajava.sql.ResultSet
.Code stanza: