[SPIGOT-6666] Bundles items ArrayList not initialized if no items in NBT were given upon instance creation Created: 22/Jul/21  Updated: 23/Jul/21  Resolved: 23/Jul/21

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: TechnicallyCoded Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: bug
Environment:

Windows 10 x64,
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9


Attachments: File SpigotApiBugReportBundles-1.0-SNAPSHOT.jar    
Version: This server is running CraftBukkit version 3188-Spigot-d03d7f1-c851639 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT)
Plugin: InventoryRollbackPlus
Guidelines Read: Yes

 Description   

Hello!

I have the following issue that I believe is caused by a subtle bug in the spigot code.

The Issue
When trying to add new items to a bundle when using the BukkitObjectOutputStream/BukkitObjectInputStream, it throws a NPE saying

java.lang.NullPointerException: Cannot invoke "java.util.List.add(Object)" because "this.items" is null

This seems to be caused by these lines I highlighted https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java#35-37,46-47.]

Related stacktrace of the NPE https://pastebin.com/raw/c7Msfd0n

 

Expected behavior

Ability to use a BukkitObjectInputStream to create a bundle object.

(Noob's suggestion for fix: Initialize the this.items array upon instance creation. This could be completely wrong but I would be interested to hear what you think the problem could be ^^)

Provided API Test Jar

Run /kill with a non-empty bundle in your inventory. (/kill is used since this bug-producing code is from the InventoryRollbackPlus plugin, which triggers on death xD)

Test Plugin source: https://github.com/TechnicallyCoded/SpigotApiBugReport-Bundles


Generated at Tue Apr 22 03:12:15 UTC 2025 using Jira 10.3.5#10030005-sha1:190c783f2bd6c69cd5accdb70f97e48812a78d14.