mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8220346: Refactor java.lang.Throwable to use Objects.requireNonNull
Reviewed-by: lancea, mchung, tvaleev, forax, martin, plevart
This commit is contained in:
parent
b5b1fe042a
commit
3a072e4e45
1 changed files with 3 additions and 6 deletions
|
@ -914,8 +914,7 @@ public class Throwable implements Serializable {
|
|||
for (Throwable t : suppressedExceptions) {
|
||||
// Enforce constraints on suppressed exceptions in
|
||||
// case of corrupt or malicious stream.
|
||||
if (t == null)
|
||||
throw new NullPointerException(NULL_CAUSE_MESSAGE);
|
||||
Objects.requireNonNull(t, NULL_CAUSE_MESSAGE);
|
||||
if (t == this)
|
||||
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
|
||||
suppressed.add(t);
|
||||
|
@ -942,8 +941,7 @@ public class Throwable implements Serializable {
|
|||
stackTrace = null;
|
||||
} else { // Verify stack trace elements are non-null.
|
||||
for(StackTraceElement ste : stackTrace) {
|
||||
if (ste == null)
|
||||
throw new NullPointerException("null StackTraceElement in serial stream. ");
|
||||
Objects.requireNonNull(ste, "null StackTraceElement in serial stream.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1034,8 +1032,7 @@ public class Throwable implements Serializable {
|
|||
if (exception == this)
|
||||
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE, exception);
|
||||
|
||||
if (exception == null)
|
||||
throw new NullPointerException(NULL_CAUSE_MESSAGE);
|
||||
Objects.requireNonNull(exception, NULL_CAUSE_MESSAGE);
|
||||
|
||||
if (suppressedExceptions == null) // Suppressed exceptions not recorded
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue