Commit abcef29
Stop ChallengesAddonTest from poisoning Tag for the rest of the JVM
Copilot was right that my earlier `Tag.LEAVES`-in-PanelTestHelper patch
didn't actually fix anything — it just touched a Tag constant that was
already broken. The real flake is upstream: ChallengesAddonTest installs
`Mockito.mockStatic(Bukkit.class)` *without* MockBukkit, then runs code
during `addon.onLoad()` that triggers `org.bukkit.Tag.<clinit>`. With
Bukkit's static methods returning null stubs at that moment, every Tag
constant is permanently set to null for the JVM — there is no way to
re-initialize an interface's static fields once <clinit> has run.
Any test later in the suite that creates an ItemStack then walks:
ItemType.<clinit>
-> Registry.ITEM.getOrThrow("acacia_hanging_sign")
-> RegistryMock.loadIfEmpty -> ItemTypeMock.from(...)
-> Class.forName("BlockStateMetaMock") -> BlockStateMetaMock.<clinit>
-> MaterialTags.<clinit>
-> Objects.requireNonNull(Tag.ALL_SIGNS) // null -> NPE
The NPE wraps as ExceptionInInitializerError, RegistryMock catches and
swallows part of it, and `acacia_hanging_sign` is missing from the
registry forever after — hence the cascade of 286 errors on CI but a
clean local run, where the test order happens to put a properly-
MockBukkit-bracketed test first.
Reproduced locally with `mvn test -Dtest=ChallengesAddonTest,
CommonPagedPanelTest -Dsurefire.runOrder=alphabetical`.
Fix: install MockBukkit briefly at the very top of
ChallengesAddonTest.setUp() and prime Tag while it's active, then
unmock immediately. Tag's static constants are now real
MaterialTagMock instances and stay valid for the rest of the JVM,
regardless of what subsequent tests do with Bukkit. As a side effect,
this also clears up ChallengesAddonTest's own pre-existing
"Settings is null" failures when it runs early in the suite.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent e459a31 commit abcef29
1 file changed
Lines changed: 12 additions & 0 deletions
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
101 | 104 | | |
102 | 105 | | |
103 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
104 | 116 | | |
105 | 117 | | |
106 | 118 | | |
| |||
0 commit comments