Repository navigation
fix(aiofighter): guard null cache inventory setup after equipping slayer gear (2.2.9) - #638
Merged
Merged
Conversation
…yer gear (2.2.9)
addInventorySetup("cache") registers the setup on the client thread, so the
immediate lookup could miss it and pass null to setCurrentSlayerInventorySetup,
which threw an NPE on getName(). Wait for the cache setup to register before
looking it up, and make the setter ignore a null setup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Client error telemetry group 2180: 1 event from 1 reporter (client 2.6.32, AIOFighter 2.2.3), thread
BankerScript-1:Root cause
When a slayer task needs protective gear,
BankerScript.withdrawUpkeepItemswithdraws and equips it, then callsinventorySetupsPlugin.addInventorySetup("cache"). If the "cache" setup does not exist yet, the client'sMInventorySetupsPlugin.addInventorySetup(String)only queues its creation withclientThread.invokeLater. The lookup on the next line (findFirst().orElse(null)) then finds nothing, and the null goes toAIOFighterPlugin.setCurrentSlayerInventorySetup, which callsgetName()without a null check.Change
AIOFighterPlugin.setCurrentSlayerInventorySetupnow ignores a null setup: it logsInventory setup not found; keeping current inventory setupand returns without writing config. This covers every caller, includingBankerScriptandInventorySetupUtil. Before, a null setup always threw, so no working behaviour is lost.BankerScripthas a new null-safe helper,findSetupByName(Collection<InventorySetup>, String).withdrawUpkeepItemsnow runssleepUntil(..., 3000)until the "cache" setup appears, then looks it up. This waits on a condition on the BankerScript thread, not on the client thread.Validation
BankerScriptCacheSetupTest(3 tests). It covers the helper (case-insensitive match, null and empty inputs, "cache" not registered yet) and checks that the setter ignores null without touching the config manager. Without the fix, the setter test fails with the original NPE../gradlew test -PpluginList=AIOFighterPlugin --tests 'net.runelite.client.plugins.microbot.aiofighter.*' --tests '...PluginManifestVersionTest': 34 tests, 0 failures.Known gaps
addInventorySetup(String)could return the setup or a future. That is out of scope for this repo.inventorySetupslist while the client thread may be adding to it. The old one-shot lookup had the same race, andsleepUntilcatches and logs exceptions.🤖 Generated with Claude Code
https://claude.ai/code/session_01LjtEMzQHGuq4M1Mpqk9pPV