diff --git a/src/main/java/net/minecraftforge/common/util/LazyOptional.java b/src/main/java/net/minecraftforge/common/util/LazyOptional.java index 4167d8969..3751c0cfa 100644 --- a/src/main/java/net/minecraftforge/common/util/LazyOptional.java +++ b/src/main/java/net/minecraftforge/common/util/LazyOptional.java @@ -29,6 +29,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import mcp.MethodsReturnNonnullByDefault; import net.minecraftforge.common.capabilities.Capability; @@ -58,6 +62,7 @@ public class LazyOptional private boolean isValid = true; private static final @Nonnull LazyOptional EMPTY = new LazyOptional<>(null); + private static final Logger LOGGER = LogManager.getLogger(); /** * Construct a new {@link LazyOptional} that wraps the given @@ -108,18 +113,14 @@ public class LazyOptional if (supplier != null) { resolved = new AtomicReference<>(null); - try - { - T temp = supplier.get(); - if (temp == null) - throw new IllegalStateException("Supplier must not return null value"); - resolved.set(temp); - return resolved.get(); - } - catch (Throwable e) + T temp = supplier.get(); + if (temp == null) { + LOGGER.catching(Level.WARN, new NullPointerException("Supplier should not return null value")); return null; } + resolved.set(temp); + return resolved.get(); } return null; }