NPE at Clan.init (line 187) and Profile.lambda$init$0 (line 175) on startup with empty MongoDB #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue
v1.1.6 fixed the Hotbar.init NPE, but there are now two new NPEs:
1. Clan.init NPE (startup failure)
This crashes during
onEnableatClan.init(Clan.java:187), called frominitManagers(wPractice.java:207). The Hotbar.init crash was atwPractice.java:198- Clan.init is the next manager being initialized (line 207 vs 198).Also note this warning before the crash:
2. Profile.lambda$init$0 NPE (runtime task)
This runs as a scheduled task (Task #12) about 2 seconds after startup. Likely an async profile initialization that depends on MongoDB data being present.
Environment (unchanged from issue #1)
mongo-minecraft.minecraft.svc.cluster.local:27017(no auth, database:practice)state=CONNECTED)PLUGINS_FILEPlayer Login
A player did connect successfully (
sqw logged in with entity id 316) and ran/pluginsand/wpractice, but the plugin is in a partially broken state due to the Clan.init crash during onEnable.Pattern
Same pattern as the Hotbar.init bug: a manager init method NPEs on an empty MongoDB database. The Clan manager (line 207) is likely querying MongoDB for clan data and getting null back on an empty database, similar to how Hotbar.init failed.
The Profile NPE (Task #12) may be related - if the plugin doesn't fully initialize due to the Clan crash, the profile scheduled task may be running against partially-initialized state.
Fixed in v1.1.7 → https://git.willowcrest.world/crypt/minecraft-practice-pvp/releases/tag/v1.1.7
Root cause:
wPractice.mongoDatabasewas never assigned fromMongoConnection.getMongoDatabase()after creating the connection inloadSaveMethod(). Every call towPractice.get().getMongoDatabase()returned null, causing the NPEs inClan.init()(line 187) andProfile.init()(line 175).Secondary issue:
MongoConnection's constructors swallowed all exceptions withcatch (Exception e) { e.printStackTrace(); }, soloadSaveMethod()'s catch handler never saw connection failures — the plugin stayed enabled with a null database instead of disabling gracefully.Fixes applied:
this.mongoDatabase = this.mongoConnection.getMongoDatabase()after connection, with null check that throwsIllegalStateExceptionto triggerloadSaveMethod's graceful disableMongoConnection— exceptions now propagateClan.init()andProfile.init()as defense-in-depth