Botarium

Botarium

28M Downloads

[1.19.2][Fabric] PlatformFluidItemHandler.getTankAmount causes Infinite Loop

gisellevonbingen opened this issue · 1 comments

commented

I saw ServerThread be paused when called PlatformFluidItemHandler.getTankAmount in fabric.
Because occur Infinite loop by 'while (storage.iterator().hasNext())' in below codes.
Looks incorrect usage of iterator.

https://github.com/terrarium-earth/Botarium/blob/6c9133a87739175682c49809fde89527bb41deef/fabric/src/main/java/earth/terrarium/botarium/fabric/fluid/FabricFluidHandler.java#L39-L46
https://github.com/terrarium-earth/Botarium/blob/b8cbebf32758abf48b9d22b17fcfbedea81f2b85/fabric/src/main/java/earth/terrarium/botarium/fabric/fluid/FabricFluidItemHandler.java#L53-L60

Must call next() of iterator in loop.
This is just example. (Not tested)

@Override
public int getTankAmount() {
	int size = 0;
	Iterator<StorageView<FluidVariant>> iterator = storage.iterator();
	while (iterator.hasNext()) {
		iterator.next();
		size++;
	}
	return size;
}
commented

Fixed in 1.17.12