Handle very early completion notification

On a Servlet container a completion notification may come at any time
even in the UNSUBSCRIBED state, i.e. before the write Publisher has
called onSubscribe.

See: gh-23553
This commit is contained in:
Rossen Stoyanchev 2019-09-12 14:14:11 +01:00
parent 07b0fa132e
commit b7eaab4c5d
2 changed files with 17 additions and 0 deletions

View File

@ -246,6 +246,17 @@ public abstract class AbstractListenerWriteFlushProcessor<T> implements Processo
super.onSubscribe(processor, subscription);
}
}
@Override
public <T> void onComplete(AbstractListenerWriteFlushProcessor<T> processor) {
// This can happen on (very early) completion notification from container..
if (processor.changeState(this, COMPLETED)) {
processor.resultPublisher.publishComplete();
}
else {
processor.state.get().onComplete(processor);
}
}
},
REQUESTED {

View File

@ -322,6 +322,12 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
super.onSubscribe(processor, subscription);
}
}
@Override
public <T> void onComplete(AbstractListenerWriteProcessor<T> processor) {
// This can happen on (very early) completion notification from container..
processor.changeStateToComplete(this);
}
},
REQUESTED {