FunctionalStorage icon indicating copy to clipboard operation
FunctionalStorage copied to clipboard

[1.21] NullPointerException: "selector" is null in ControllerInventoryHandler.insertItem when Storage Controller is accessed by external mods (Ars Nouveau Storage Lectern)

Open tstolswo opened this issue 5 months ago • 0 comments

Functional Storage Version: 1.21.1-1.5.7

Titanium Version: titanium-1.21-4.0.43.jar

Crashlog If Applicable (Upload to pastebin/gist): https://gist.github.com/tstolswo/2aea6e87b37a93829aec502bf0cd9577

A NullPointerException is thrown during server tick when an Ars Nouveau Storage Lectern attempts to insert items into a Functional Storage Controller. The crash occurs inside ControllerInventoryHandler.insertItem because the selector field on the handler is null.

The crash appears to be triggered or made likely by an unclean server shutdown (in our case, a separate watchdog timeout crash), after which the Storage Controller reloads with a null selector reference. On the next server tick where the Storage Lectern attempts insertNearbyItems , the null reference causes a fatal crash. To Reproduce

  1. Place a Functional Storage Controller with drawers linked to it
  2. Place an Ars Nouveau Storage Lectern adjacent to or near the controller
  3. Have the Storage Lectern configured to push items into nearby inventories
  4. Cause an unclean server shutdown (e.g., forced kill, watchdog crash, OOM)
  5. Restart the server — on the first tick where the Storage Lectern processes, the server crashes

│ Note: It may also be reproducible without the unclean shutdown — we haven't confirmed whether the null selector can arise in a clean session, or only after a dirty one.

Expected behavior

ControllerInventoryHandler.insertItem should null-check selector before dereferencing it, and either skip the insertion gracefully or return ItemStack.EMPTY rather than throwing.

Crash Report / Stack Trace

java.lang.NullPointerException: Cannot read field "handler" because "selector" is null
    at com.buuz135.functionalstorage.inventory.ControllerInventoryHandler.insertItem(ControllerInventoryHandler.java:94)
    at com.hollingsworth.arsnouveau.api.item.inv.FilterableItemHandler.insertItemStacked(FilterableItemHandler.java:119)
    at com.hollingsworth.arsnouveau.api.item.inv.InventoryManager.insertStackWithReference(InventoryManager.java:85)
    at com.hollingsworth.arsnouveau.common.block.tile.StorageLecternTile.pushStack(StorageLecternTile.java:234)
    at com.hollingsworth.arsnouveau.common.block.tile.StorageLecternTile.pushStack(StorageLecternTile.java:250)
    at com.hollingsworth.arsnouveau.common.block.tile.StorageLecternTile.insertNearbyItems(StorageLecternTile.java:469)
    at com.hollingsworth.arsnouveau.common.block.tile.StorageLecternTile.tick(StorageLecternTile.java:355)

Block location at time of crash: World: (0, 128, 29) — ars_nouveau:storage_lectern facing north Environment

Functional Storage 1.21.1-1.5.7
Ars Nouveau 5.11.6
NeoForge 21.1.233
Minecraft 1.21.1
Java 21.0.4 (Eclipse Adoptium)
OS Windows Server 2022 (amd64)
Modpack FTB StoneBlock 4 1.14.2
Additional context

• The crash is reproducible on a dedicated server; this is not a client-side issue • The selector field going null on reload after a dirty shutdown suggests the controller's state is not being fully re-initialized on world load — a null check at line 94 of ControllerInventoryHandler would at minimum prevent the server crash, though the root cause (null selector on reload) may warrant a separate fix in the deserialization/load path

tstolswo avatar Jun 10 '26 23:06 tstolswo