Skip to content

Commit

Permalink
Check null before grabbing metadata owning plugin. Fixes BUKKIT-4665
Browse files Browse the repository at this point in the history
MetadataStoreBase throws a NullPointerException when passed a null value
for setMetaData. The intended behavior is to throw an
IllegalArgumentException. This commit changes the value's null check to
occur before referencing the owning plugin of a value.
  • Loading branch information
MisterVector authored and Wolvereness committed Aug 7, 2013
1 parent e7f3d55 commit bb628f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/bukkit/metadata/MetadataStoreBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public abstract class MetadataStoreBase<T> {
* @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);
Expand Down

0 comments on commit bb628f8

Please sign in to comment.