Skip to content

Commit

Permalink
Fail on WrappedCheckedException constructor validation before calling…
Browse files Browse the repository at this point in the history
… super
  • Loading branch information
bkoprucu committed Dec 8, 2024
1 parent e3b107f commit 90b51c8
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import static java.util.Objects.requireNonNull;

/**
* A runtime exception dedicated to wrapping checked exceptions.
Expand All @@ -19,11 +20,8 @@ public final class WrappedCheckedException extends RuntimeException
*/
private WrappedCheckedException(String message, Throwable cause)
{
super(message, cause);
if (message == null)
throw new NullPointerException("message may not be null");
if (cause == null)
throw new NullPointerException("cause may not be null");
super(requireNonNull(message, "message cannot be null"),
requireNonNull(cause, "cause cannot be null"));
}

/**
Expand All @@ -34,9 +32,7 @@ private WrappedCheckedException(String message, Throwable cause)
*/
private WrappedCheckedException(Throwable cause)
{
super(cause);
if (cause == null)
throw new NullPointerException("cause may not be null");
super(requireNonNull(cause, "cause cannot be null"));
}

/**
Expand Down

0 comments on commit 90b51c8

Please sign in to comment.