Skip to content

Commit 77dae05

Browse files
committed
Validating non-null values passed to InMemoryState
1 parent b41bc84 commit 77dae05

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

opamp-client/src/main/java/io/opentelemetry/opamp/client/internal/state/InMemoryState.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ abstract class InMemoryState<T> implements State<T> {
1717
private final AtomicReference<T> state = new AtomicReference<>();
1818

1919
public InMemoryState(T initialValue) {
20+
if (initialValue == null) {
21+
throw new IllegalArgumentException("The value must not be null");
22+
}
2023
state.set(initialValue);
2124
}
2225

2326
public void set(T value) {
27+
if (value == null) {
28+
throw new IllegalArgumentException("The value must not be null");
29+
}
2430
state.set(value);
2531
}
2632

0 commit comments

Comments
 (0)