Industrial Foregoing

Industrial Foregoing

95M Downloads

[Crash] StrawUtils tries to sort immutable list causing crash

Linguardium opened this issue ยท 0 comments

commented

@NotNull List<StrawHandler> current = IFRegistries.STRAW_HANDLER_REGISTRY.stream().toList();
current.sort(Comparator.comparingInt(StrawHandler::getPriority));

toList does not guarantee on mutability. the List.sort mutates the list. Instead something like this should be used:

stream.collect(Collectors.toCollection(ArrayList::new))

or the stream should be sorted before collection to the potentially immutable list

stream.sorted(Comparator.comparingInt(StrawHandler::getPriority)).toList()