HTTP/2 DefaultHttp2HeadersDecoder weighted average error
Motiviation:
cfcee5798d
introduced code to resize the headers based upon a weighted average. The weight used for new entries was initialized using integer arithmetic when it should have been floating point arithmetic and so new values contribute 0 weight.
Modifications:
- Cast to float when initializing
Result:
Weighted average does not give 0 weight to new headers in DefaultHttp2HeadersDecoder.
This commit is contained in:
parent
9aac6dac2e
commit
4b5b230802
@ -33,7 +33,7 @@ import static io.netty.handler.codec.http2.Http2Error.PROTOCOL_ERROR;
|
|||||||
import static io.netty.handler.codec.http2.Http2Exception.connectionError;
|
import static io.netty.handler.codec.http2.Http2Exception.connectionError;
|
||||||
|
|
||||||
public class DefaultHttp2HeadersDecoder implements Http2HeadersDecoder, Http2HeadersDecoder.Configuration {
|
public class DefaultHttp2HeadersDecoder implements Http2HeadersDecoder, Http2HeadersDecoder.Configuration {
|
||||||
private static final float HEADERS_COUNT_WEIGHT_NEW = 1 / 5;
|
private static final float HEADERS_COUNT_WEIGHT_NEW = 1 / 5f;
|
||||||
private static final float HEADERS_COUNT_WEIGHT_HISTORICAL = 1 - HEADERS_COUNT_WEIGHT_NEW;
|
private static final float HEADERS_COUNT_WEIGHT_HISTORICAL = 1 - HEADERS_COUNT_WEIGHT_NEW;
|
||||||
|
|
||||||
private final int maxHeaderSize;
|
private final int maxHeaderSize;
|
||||||
@ -109,8 +109,8 @@ public class DefaultHttp2HeadersDecoder implements Http2HeadersDecoder, Http2Hea
|
|||||||
headers.size(), headerTable.maxHeaderListSize());
|
headers.size(), headerTable.maxHeaderListSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
headerArraySizeAccumulator = HEADERS_COUNT_WEIGHT_NEW * headers.size() +
|
headerArraySizeAccumulator = HEADERS_COUNT_WEIGHT_NEW * headers.size() +
|
||||||
HEADERS_COUNT_WEIGHT_HISTORICAL * headerArraySizeAccumulator;
|
HEADERS_COUNT_WEIGHT_HISTORICAL * headerArraySizeAccumulator;
|
||||||
return headers;
|
return headers;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw connectionError(COMPRESSION_ERROR, e, e.getMessage());
|
throw connectionError(COMPRESSION_ERROR, e, e.getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user