From f4f8817fd5d3bacfc28e18ce49aed97ef03dbde3 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Thu, 13 Mar 2014 03:34:51 +0100 Subject: [PATCH] Undo mocking when we're done with the test. --- .../java/com/comphenix/protocol/utility/CachedPackage.java | 6 +++++- .../comphenix/protocol/utility/MinecraftReflectionTest.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java index 8f8e1b49..8102f893 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/CachedPackage.java @@ -19,6 +19,7 @@ package com.comphenix.protocol.utility; import java.util.Map; +import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.Maps; @@ -60,12 +61,15 @@ class CachedPackage { */ public Class getPackageClass(String className) { try { - Class result = cache.get(className); + Class result = cache.get(Preconditions.checkNotNull(className, "className cannot be NULL")); // Concurrency is not a problem - we don't care if we look up a class twice if (result == null) { // Look up the class dynamically result = source.loadClass(combine(packageName, className)); + + if (result == null) + throw new IllegalArgumentException("Source " + source + " returned NULL for " + className); cache.put(className, result); } return result; diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java index 23ea2499..b7b3d181 100644 --- a/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/utility/MinecraftReflectionTest.java @@ -45,6 +45,7 @@ public class MinecraftReflectionTest { @AfterClass public static void undoMocking() { // NOP + MinecraftReflection.minecraftPackage = null; } @Test