Skip to content

Conversation

@phinner
Copy link

@phinner phinner commented Jan 5, 2026

Information

NPEs will occur if PermissionsHandler.handler#getGroups(OfflinePlayer) returns null.
Which is the case if PermissionsHandler.handler is SuperpermsHandler for example.
This results in console spam which is quite unpleasant :(.

Example:

[15:03:48] [Craft Scheduler Thread - 10 - Essentials/WARN]: [Essentials] Plugin Essentials v2.22.0-dev+53-9ad754b generated an exception while executing task 53
java.lang.NullPointerException: Cannot invoke "java.util.Collection.toArray()" because "c" is null
	at java.base/java.util.ArrayList.addAll(ArrayList.java:752) ~[?:?]
	at EssentialsX-2.22.0-dev+53-9ad754b.jar/com.earth2me.essentials.perm.PermissionsHandler.getGroups(PermissionsHandler.java:61) ~[EssentialsX-2.22.0-dev+53-9ad754b.jar:?]
	at EssentialsXDiscordLink-2.21.2.jar/net.essentialsx.discordlink.rolesync.RoleSyncManager.sync(RoleSyncManager.java:63) ~[EssentialsXDiscordLink-2.21.2.jar:?]
	at EssentialsXDiscordLink-2.21.2.jar/net.essentialsx.discordlink.rolesync.RoleSyncManager.lambda$new$0(RoleSyncManager.java:46) ~[EssentialsXDiscordLink-2.21.2.jar:?]
	at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:78) ~[purpur-1.21.10.jar:1.21.10-2531-b7b7ba2]
	at org.bukkit.craftbukkit.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[purpur-1.21.10.jar:1.21.10-2531-b7b7ba2]
	at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[purpur-1.21.10.jar:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
	at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

Details

Proposed fix:

The straighforward solution is to simply add a null check like the other methods of PermissionsHandler.

I also thought about copying and adapting the method body of PermissionsHandler#getGroups() such as

List<String> groups = handler.getGroups(base);
if (groups == null || groups.isEmpty()) {
  groups = Collections.singletonList(defaultGroup);
}

But that would change the behavior of PermissionsHandler#getGroups(OfflinePlayer) by no longer returning the default group as the first group, so I did not.

Environments tested:

OS: Linux (docker)

Java version: 21

  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8
  • Purpur 1.21.10-2531-HEAD@b7b7ba2 (Implementing API version 1.21.10-R0.1-SNAPSHOT)

Demonstration:

N/A, the log spam just stops.

@phinner phinner changed the title fix: Fix NPE in PermissionsHandler#getGroups(OfflinePlayer) Fix NPE in PermissionsHandler#getGroups(OfflinePlayer) Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant