GT New Horizons

GT New Horizons

867k Downloads

NEI Item List Search occasionally breaks

lailani-f opened this issue ยท 1 comments

commented

Your GTNH Discord Username

cure.starlight

Your Pack Version

Nightly 804

Your Server

Zeta

Java Version

Java 21

Type of Server

Don't know

Your Expectation

NEI Item Search to work reliably.

The Reality

NEI Search sometimes stops working. It won't start working again until the client is restarted.

In the logs

[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.HashMap.get(Object)" is null
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at Launch//codechicken.nei.ItemList$3.compare(ItemList.java:391)
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:355)
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at java.base/java.util.TimSort.sort(TimSort.java:234)
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at java.base/java.util.Arrays.sort(Arrays.java:1308)
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at java.base/java.util.ArrayList.sort(ArrayList.java:1804)
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at Launch//codechicken.nei.ItemList$3.execute(ItemList.java:412)
[NEI Item Filtering/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:785]:     at Launch//codechicken.nei.RestartableTask$1.run(RestartableTask.java:25)

Method in question: https://github.com/GTNewHorizons/NotEnoughItems/blob/master/src/main/java/codechicken/nei/ItemList.java#L236
It might be a race condition between the two tasks loadItems and updateFilter when loadItems gets triggered while updateFilter is still running. In this case loadItems empties the HashMap that updateFilter relies on effectively causing the NPE during comparison operations.

I was unable to reproduce the issue reliably but it can happen when switching dimensions.

Your Proposal

Ensure the NPE cannot occur.

Final Checklist

  • I have searched this issue tracker and there is nothing similar already. Posting on a closed issue saying the bug still exists will prompt us to investigate and reopen it once we confirm your report.
  • I can reproduce this problem consistently by follow the exact steps I described above, or this does not need reproducing, e.g. recipe loophole.
  • I have asked other people and they confirm they also have this problem by follow the exact steps I described above, or this does not need reproducing, e.g. recipe loophole.
commented

I have same problem at 804 but restart did't help me.
Delete folder config/NEI help me