From 9fb31973757a3ad4509c024ea50e77295c61cf89 Mon Sep 17 00:00:00 2001 From: Jared Jacobs Date: Fri, 10 Feb 2017 15:11:48 -0800 Subject: Avoid "possible NPE" warnings for throw Lombok.sneakyThrow(e) Currently, the following code triggers a warning in IntelliJ. (I'm using the current version, 2016.3.4.) throw Lombok.sneakyThrow(e); > Dereference of 'Lombok.sneakyThrow(e)' may produce 'java.lang.NullPointerException'. This change eliminates the warning. All tests pass. I ran: ant setupJavaOpenJDK6TestEnvironment ant test ant setupJavaOpenJDK7TestEnvironment ant test ant setupJavaOracle7TestEnvironment ant test ant setupJavaOracle8TestEnvironment ant test --- src/core/lombok/Lombok.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/lombok/Lombok.java b/src/core/lombok/Lombok.java index 310b57e3..ae375637 100644 --- a/src/core/lombok/Lombok.java +++ b/src/core/lombok/Lombok.java @@ -48,12 +48,11 @@ public class Lombok { */ public static RuntimeException sneakyThrow(Throwable t) { if (t == null) throw new NullPointerException("t"); - Lombok.sneakyThrow0(t); - return null; + return Lombok.sneakyThrow0(t); } @SuppressWarnings("unchecked") - private static void sneakyThrow0(Throwable t) throws T { + private static RuntimeException sneakyThrow0(Throwable t) throws T { throw (T)t; } -- cgit