mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +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) {
|
for (Throwable t : suppressedExceptions) {
|
||||||
// Enforce constraints on suppressed exceptions in
|
// Enforce constraints on suppressed exceptions in
|
||||||
// case of corrupt or malicious stream.
|
// case of corrupt or malicious stream.
|
||||||
if (t == null)
|
Objects.requireNonNull(t, NULL_CAUSE_MESSAGE);
|
||||||
throw new NullPointerException(NULL_CAUSE_MESSAGE);
|
|
||||||
if (t == this)
|
if (t == this)
|
||||||
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
|
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE);
|
||||||
suppressed.add(t);
|
suppressed.add(t);
|
||||||
|
@ -942,8 +941,7 @@ public class Throwable implements Serializable {
|
||||||
stackTrace = null;
|
stackTrace = null;
|
||||||
} else { // Verify stack trace elements are non-null.
|
} else { // Verify stack trace elements are non-null.
|
||||||
for(StackTraceElement ste : stackTrace) {
|
for(StackTraceElement ste : stackTrace) {
|
||||||
if (ste == null)
|
Objects.requireNonNull(ste, "null StackTraceElement in serial stream.");
|
||||||
throw new NullPointerException("null StackTraceElement in serial stream. ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1034,8 +1032,7 @@ public class Throwable implements Serializable {
|
||||||
if (exception == this)
|
if (exception == this)
|
||||||
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE, exception);
|
throw new IllegalArgumentException(SELF_SUPPRESSION_MESSAGE, exception);
|
||||||
|
|
||||||
if (exception == null)
|
Objects.requireNonNull(exception, NULL_CAUSE_MESSAGE);
|
||||||
throw new NullPointerException(NULL_CAUSE_MESSAGE);
|
|
||||||
|
|
||||||
if (suppressedExceptions == null) // Suppressed exceptions not recorded
|
if (suppressedExceptions == null) // Suppressed exceptions not recorded
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue