Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Check null before grabbing owning plugin - fixes BUKKIT-3987 #843

wants to merge 1 commit into from

3 participants


The null validation check comes after the owning plugin is extracted from it, resulting in a possible NPE if a null value is passed to the method.

The issue:

A validation check is called to make sure that the metadata value passed in is not null. However, another call, which gets the owning plugin of the metadata value, gets called before this validation check is called, resulting in an NPE if the value passed into the method is null.

Bukkit Ticket:



As sad as it sounds, can testing material be provided for this?

And can this be modified to follow the file please?

@Wolvereness Wolvereness closed this
@AlphaBlend AlphaBlend deleted the AlphaBlend:CheckNullFirst branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 5, 2013
  1. @AlphaBlend
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/main/java/org/bukkit/metadata/
2  src/main/java/org/bukkit/metadata/
@@ -25,8 +25,8 @@
* @throws IllegalArgumentException If value is null, or the owning plugin is null
public synchronized void setMetadata(T subject, String metadataKey, MetadataValue newMetadataValue) {
- Plugin owningPlugin = newMetadataValue.getOwningPlugin();
Validate.notNull(newMetadataValue, "Value cannot be null");
+ Plugin owningPlugin = newMetadataValue.getOwningPlugin();
Validate.notNull(owningPlugin, "Plugin cannot be null");
String key = disambiguate(subject, metadataKey);
Map<Plugin, MetadataValue> entry = metadataMap.get(key);
Something went wrong with that request. Please try again.