Check null before grabbing metadata owning plugin. Fixes BUKKIT-4665

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.

By: AlphaBlend <whizkid3000@hotmail.com>
This commit is contained in:
Bukkit/Spigot 2013-04-04 17:00:26 -07:00
parent d8cfc3fa42
commit 121764ab61

View file

@ -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);