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 ad4f0e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 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)
@ConditionalOnProperty(prefix = PREFIX, name = "max-concurrent-streams")
WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
@Value("${" + PREFIX + ".max-concurrent-streams:2147483647}") int maxConcurrentStreams) {
@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)
@ConditionalOnProperty(prefix = PREFIX, name = "max-concurrent-streams")
WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
@Value("${" + PREFIX + ".max-concurrent-streams:2147483647}") int maxConcurrentStreams) {
@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 ad4f0e1

Please sign in to comment.