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 authored and cowwoc committed Dec 12, 2024
1 parent a8a8340 commit 98f7437
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,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 @@ -21,11 +22,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 @@ -36,9 +34,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 98f7437

Please sign in to comment.