HTTP/2 SimplePromiseAggregator tryFailure not consistent with setFailure
Motivation: The SimplePromiseAggregator.setFailure allows a failure to occur before newPromise is called, but tryFailure doesn't. These methods should be consistent. Modifications: - tryFailure should use the same logic as setFailure Result: Consistent failure routines.
This commit is contained in:
parent
7a9a3159f9
commit
0736a3bc35
@ -240,7 +240,7 @@ public final class Http2CodecUtil {
|
||||
|
||||
@Override
|
||||
public boolean tryFailure(Throwable cause) {
|
||||
if (awaitingPromises()) {
|
||||
if (allowFailure()) {
|
||||
++failureCount;
|
||||
if (failureCount == 1) {
|
||||
promise.tryFailure(cause);
|
||||
@ -261,7 +261,7 @@ public final class Http2CodecUtil {
|
||||
*/
|
||||
@Override
|
||||
public ChannelPromise setFailure(Throwable cause) {
|
||||
if (awaitingPromises() || expectedCount == 0) {
|
||||
if (allowFailure()) {
|
||||
++failureCount;
|
||||
if (failureCount == 1) {
|
||||
promise.setFailure(cause);
|
||||
@ -271,6 +271,10 @@ public final class Http2CodecUtil {
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean allowFailure() {
|
||||
return awaitingPromises() || expectedCount == 0;
|
||||
}
|
||||
|
||||
private boolean awaitingPromises() {
|
||||
return successfulCount + failureCount < expectedCount;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user