Ensure state of PartGenerator accepts buffers
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
This commit is contained in:
@@ -229,6 +229,7 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
|
||||
if (upstream() != null &&
|
||||
!this.sink.isCancelled() &&
|
||||
this.sink.requestedFromDownstream() > 0 &&
|
||||
this.state.get().canRequest() &&
|
||||
this.requestOutstanding.compareAndSet(false, true)) {
|
||||
request(1);
|
||||
}
|
||||
@@ -291,6 +292,13 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
|
||||
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.
|
||||
*/
|
||||
@@ -814,6 +822,11 @@ final class PartGenerator extends BaseSubscriber<MultipartParser.Token> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRequest() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
this.disposed = true;
|
||||
|
||||
Reference in New Issue
Block a user