Java · Medium · Pro
Debug: UnsupportedOperationException when cleaning a list
JavaCollectionsTrickySenior
Removing inactive IDs crashes at runtime.
Java
List<String> all = repository.findAllIds();
List<String> view = all.subList(0, Math.min(50, all.size()));
for (String id : view) {
if (isInactive(id)) {
view.remove(id);
}
}Root cause
subListview does not support structural modification via its own iterator/remove.