Skip to content

Commit

Permalink
Ensure state of PartGenerator accepts buffers
Browse files Browse the repository at this point in the history
This commit makes sure that the current state of the PartGenerator
is able to handle an incoming buffer, possibly requested because of
a request coming from the subscription. All states accept new buffers
except the WritingFileState.

Closes gh-29227
  • Loading branch information
poutsma committed Oct 27, 2022
1 parent 51d109d commit 4632985
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -229,6 +229,7 @@ void requestToken() {
if (upstream() != null &&
!this.sink.isCancelled() &&
this.sink.requestedFromDownstream() > 0 &&
this.state.get().canRequest() &&
this.requestOutstanding.compareAndSet(false, true)) {
request(1);
}
Expand Down Expand Up @@ -291,6 +292,13 @@ private interface State {
default void error(Throwable throwable) {
}

/**
* Indicates whether the current state is ready to accept a new token.
*/
default boolean canRequest() {
return true;
}

/**
* Cleans up any state.
*/
Expand Down Expand Up @@ -814,6 +822,11 @@ private Mono<Void> writeInternal(DataBuffer dataBuffer) {
}
}

@Override
public boolean canRequest() {
return false;
}

@Override
public void dispose() {
this.disposed = true;
Expand Down

0 comments on commit 4632985

Please sign in to comment.