Java

Java

Made by DeepSource

Avoid throwing null JAVA-E1097

Bug risk
Critical
Autofix

Throwing null is a bad practice and should be avoided, as it serves no meaningful purpose.

Throwing a literal null value will cause Java to throw a NullPointerException instead.

Bad Practice

throw null;

Recommended

If you need to throw a NullPointerException, do so directly.

throw new NullPointerException("something was null!");