diff options
author | Jared Jacobs <jaredjacobs@forwardnetworks.com> | 2017-02-10 15:11:48 -0800 |
---|---|---|
committer | Jared Jacobs <jaredjacobs@forwardnetworks.com> | 2017-07-28 17:35:45 -0700 |
commit | 9fb31973757a3ad4509c024ea50e77295c61cf89 (patch) | |
tree | 82ceaa269927f1e4baee4f9bf8232685c1ccbf53 | |
parent | 7516a51b378914060f2c302197e115829718167e (diff) | |
download | lombok-9fb31973757a3ad4509c024ea50e77295c61cf89.tar.gz lombok-9fb31973757a3ad4509c024ea50e77295c61cf89.tar.bz2 lombok-9fb31973757a3ad4509c024ea50e77295c61cf89.zip |
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
-rw-r--r-- | src/core/lombok/Lombok.java | 5 |
1 files 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.<RuntimeException>sneakyThrow0(t); - return null; + return Lombok.<RuntimeException>sneakyThrow0(t); } @SuppressWarnings("unchecked") - private static <T extends Throwable> void sneakyThrow0(Throwable t) throws T { + private static <T extends Throwable> RuntimeException sneakyThrow0(Throwable t) throws T { throw (T)t; } |