Skip to content

Commit

Permalink
Does not override defaults max stream size
Browse files Browse the repository at this point in the history
  • Loading branch information
oxsean committed Sep 27, 2024
1 parent 68e3b5e commit ba8b290
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class ServletConfig implements Serializable {
/**
* Maximum concurrent streams.
* <p>For HTTP/2
* <p>The default value is {@link Integer#MAX_VALUE}.
* <p>Note that the default value for tomcat is 20. Highly recommended to change it to {@link Integer#MAX_VALUE}
* <p>If set to a negative number, the actual value will be set to {@link Integer#MAX_VALUE}.
*/
private Integer maxConcurrentStreams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class DubboTriple3AutoConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Filter.class)
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnProperty(prefix = PREFIX, name = "enabled")
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
public static class TripleServletConfiguration {

@Bean
Expand All @@ -62,15 +62,17 @@ public FilterRegistrationBean<TripleFilter> tripleProtocolFilter(

@Bean
@ConditionalOnClass(Http2Protocol.class)
WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
@Value("${" + PREFIX + ".max-concurrent-streams:2147483647}") int maxConcurrentStreams) {
@ConditionalOnProperty(prefix = PREFIX, name = "max-concurrent-streams")
public WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
@Value("${" + PREFIX + ".max-concurrent-streams}") int maxConcurrentStreams) {
return factory -> factory.addConnectorCustomizers(connector -> {
ProtocolHandler handler = connector.getProtocolHandler();
for (UpgradeProtocol upgradeProtocol : handler.findUpgradeProtocols()) {
if (upgradeProtocol instanceof Http2Protocol) {
Http2Protocol protocol = (Http2Protocol) upgradeProtocol;
protocol.setMaxConcurrentStreams(maxConcurrentStreams);
protocol.setMaxConcurrentStreamExecution(maxConcurrentStreams);
int value = maxConcurrentStreams < 0 ? Integer.MAX_VALUE : maxConcurrentStreams;
protocol.setMaxConcurrentStreams(value);
protocol.setMaxConcurrentStreamExecution(value);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class DubboTripleAutoConfiguration {
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Filter.class)
@ConditionalOnWebApplication(type = Type.SERVLET)
@ConditionalOnProperty(prefix = PREFIX, name = "enabled")
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
public static class TripleServletConfiguration {

@Bean
Expand All @@ -63,15 +63,17 @@ public FilterRegistrationBean<TripleFilter> tripleProtocolFilter(

@Bean
@ConditionalOnClass(Http2Protocol.class)
WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
@Value("${" + PREFIX + ".max-concurrent-streams:2147483647}") int maxConcurrentStreams) {
@ConditionalOnProperty(prefix = PREFIX, name = "max-concurrent-streams")
public WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
@Value("${" + PREFIX + ".max-concurrent-streams}") int maxConcurrentStreams) {
return factory -> factory.addConnectorCustomizers(connector -> {
ProtocolHandler handler = connector.getProtocolHandler();
for (UpgradeProtocol upgradeProtocol : handler.findUpgradeProtocols()) {
if (upgradeProtocol instanceof Http2Protocol) {
Http2Protocol protocol = (Http2Protocol) upgradeProtocol;
protocol.setMaxConcurrentStreams(maxConcurrentStreams);
protocol.setMaxConcurrentStreamExecution(maxConcurrentStreams);
int value = maxConcurrentStreams < 0 ? Integer.MAX_VALUE : maxConcurrentStreams;
protocol.setMaxConcurrentStreams(value);
protocol.setMaxConcurrentStreamExecution(value);
}
}
});
Expand Down

0 comments on commit ba8b290

Please sign in to comment.