Skip to content

Commit

Permalink
Add validation for H1ProtocolConfigBuilder setters (#2792)
Browse files Browse the repository at this point in the history
Motivation:

`H1ProtocolConfigBuilder` does not validate incoming int parameters.
  • Loading branch information
idelpivnitskiy authored Dec 21, 2023
1 parent e3daaf3 commit aeca73c
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public H1ProtocolConfigBuilder headersFactory(final HttpHeadersFactory headersFa
* @return {@code this}
*/
public H1ProtocolConfigBuilder maxPipelinedRequests(final int maxPipelinedRequests) {
if (maxPipelinedRequests <= 0) {
throw new IllegalArgumentException("maxPipelinedRequests: " + maxPipelinedRequests + " (expected >0)");
}
this.maxPipelinedRequests = maxPipelinedRequests;
return this;
}
Expand All @@ -83,6 +86,9 @@ public H1ProtocolConfigBuilder maxPipelinedRequests(final int maxPipelinedReques
* @return {@code this}
*/
public H1ProtocolConfigBuilder maxStartLineLength(final int maxStartLineLength) {
if (maxStartLineLength <= 0) {
throw new IllegalArgumentException("maxStartLineLength: " + maxStartLineLength + " (expected >0)");
}
this.maxStartLineLength = maxStartLineLength;
return this;
}
Expand All @@ -100,6 +106,9 @@ public H1ProtocolConfigBuilder maxStartLineLength(final int maxStartLineLength)
* @return {@code this}
*/
public H1ProtocolConfigBuilder maxHeaderFieldLength(final int maxHeaderFieldLength) {
if (maxHeaderFieldLength <= 0) {
throw new IllegalArgumentException("maxHeaderFieldLength: " + maxHeaderFieldLength + " (expected >0)");
}
this.maxHeaderFieldLength = maxHeaderFieldLength;
return this;
}
Expand All @@ -116,6 +125,10 @@ public H1ProtocolConfigBuilder maxHeaderFieldLength(final int maxHeaderFieldLeng
* @return {@code this}
*/
public H1ProtocolConfigBuilder headersEncodedSizeEstimate(final int headersEncodedSizeEstimate) {
if (headersEncodedSizeEstimate <= 0) {
throw new IllegalArgumentException("headersEncodedSizeEstimate: " + headersEncodedSizeEstimate +
" (expected >0)");
}
this.headersEncodedSizeEstimate = headersEncodedSizeEstimate;
return this;
}
Expand All @@ -130,6 +143,10 @@ public H1ProtocolConfigBuilder headersEncodedSizeEstimate(final int headersEncod
* @return {@code this}
*/
public H1ProtocolConfigBuilder trailersEncodedSizeEstimate(final int trailersEncodedSizeEstimate) {
if (trailersEncodedSizeEstimate <= 0) {
throw new IllegalArgumentException("trailersEncodedSizeEstimate: " + trailersEncodedSizeEstimate +
" (expected >0)");
}
this.trailersEncodedSizeEstimate = trailersEncodedSizeEstimate;
return this;
}
Expand Down

0 comments on commit aeca73c

Please sign in to comment.