When
player.getInventory().addItem(new ItemStack(Material.AIR));
is called, the server immediately starts consuming all available memory and freezes. Players time out and the server thread appears to be dead. There is no immediate error message, but errors like
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Spigot Watchdog Thread"
will start appearing after ~30 seconds. Sometimes the server also crashes completely with a thread dump.
Minimal command example:
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player) ((Player) sender).getInventory().addItem(new ItemStack(Material.AIR)); return false; }
I am aware that adding AIR to an inventory is pretty useless, but the server should not crash regardless.
1.21.4 appears to be also affected by this issue.