Skip to content

Commit 89ae63a

Browse files
author
Carter Kozak
authored
Ensure QosReason cannot be null (#929)
Ensure QosReason cannot be provided as `null` by throwing an exception immediately
1 parent f88463f commit 89ae63a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: improvement
2+
improvement:
3+
description: Ensure QosReason cannot be provided as `null` by throwing an exception
4+
immediately
5+
links:
6+
- https://github.com/palantir/conjure-java-runtime-api/pull/929

errors/src/main/java/com/palantir/conjure/java/api/errors/QosException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.palantir.conjure.java.api.errors;
1818

1919
import com.palantir.logsafe.Arg;
20+
import com.palantir.logsafe.Preconditions;
2021
import com.palantir.logsafe.SafeArg;
2122
import com.palantir.logsafe.SafeLoggable;
2223
import com.palantir.logsafe.UnsafeArg;
@@ -39,12 +40,12 @@ public abstract class QosException extends RuntimeException {
3940
// Not meant for external subclassing.
4041
private QosException(String message, QosReason reason) {
4142
super(message);
42-
this.reason = reason;
43+
this.reason = Preconditions.checkNotNull(reason, "QosReason is required");
4344
}
4445

4546
private QosException(String message, Throwable cause, QosReason reason) {
4647
super(message, cause);
47-
this.reason = reason;
48+
this.reason = Preconditions.checkNotNull(reason, "QosReason is required");
4849
}
4950

5051
public final QosReason getReason() {

0 commit comments

Comments
 (0)