[SPIGOT-7399] NPE if object is null Created: 17/Jun/23  Updated: 25/Dec/24  Resolved: 17/Jun/23

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

Type: Bug Priority: Minor
Reporter: Mersphydena Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: None
Environment:

 

 


Version: 1.20
Guidelines Read: Yes

 Description   

Caused by: java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "object" is null

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/40945171bf8a5a234ed084386ef6b89070d2a4e3#src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java?f=1333



 Comments   
Comment by Mersphydena [ 17/Jun/23 ]

{{ Preconditions.checkArgument(object == null, "%s cannot contain non-string %s", addFrom, object.getClass().getName());}}

If "object" is null, object.getClass() is going to throw a NPE?

before commit

if object wasn't null and was anything other than string, throw error

object can be null, and it adds an empty line 

after commit

if object null, throw error that NPEs

 

Comment by md_5 [ 17/Jun/23 ]

Can you please provide the full code / stack trace. I'm struggling to see the issue

Generated at Fri Apr 11 16:22:09 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.