Skip to content

Commit

Permalink
Prevent null from being put into the FlowControlledBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDrivenMitch committed Jul 8, 2022
1 parent 4e38024 commit 61a13f7
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public abstract class FlowControlledBuffer<T, R> extends FlowControlledStream<T,
*/
public FlowControlledBuffer(String clientId, int bufferSize, int refillBatch) {
super(clientId, bufferSize, refillBatch);
if (terminalMessage() == null) {
throw new IllegalStateException("Terminal message is not allowed to be null");
}
}

/**
Expand All @@ -57,6 +60,9 @@ public FlowControlledBuffer(String clientId, int bufferSize, int refillBatch) {

@Override
public void onNext(T value) {
if (value == null) {
throw new NullPointerException("Next value of buffer is not allowed to be null");
}
buffer.offer(value);
}

Expand Down

0 comments on commit 61a13f7

Please sign in to comment.