Skip to content

Commit ba8b290

Browse files
committed
Does not override defaults max stream size
1 parent 68e3b5e commit ba8b290

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

dubbo-common/src/main/java/org/apache/dubbo/config/nested/ServletConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public class ServletConfig implements Serializable {
3131
/**
3232
* Maximum concurrent streams.
3333
* <p>For HTTP/2
34-
* <p>The default value is {@link Integer#MAX_VALUE}.
34+
* <p>Note that the default value for tomcat is 20. Highly recommended to change it to {@link Integer#MAX_VALUE}
35+
* <p>If set to a negative number, the actual value will be set to {@link Integer#MAX_VALUE}.
3536
*/
3637
private Integer maxConcurrentStreams;
3738

dubbo-spring-boot/dubbo-spring-boot-3-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboTriple3AutoConfiguration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class DubboTriple3AutoConfiguration {
4444
@Configuration(proxyBeanMethods = false)
4545
@ConditionalOnClass(Filter.class)
4646
@ConditionalOnWebApplication(type = Type.SERVLET)
47-
@ConditionalOnProperty(prefix = PREFIX, name = "enabled")
47+
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
4848
public static class TripleServletConfiguration {
4949

5050
@Bean
@@ -62,15 +62,17 @@ public FilterRegistrationBean<TripleFilter> tripleProtocolFilter(
6262

6363
@Bean
6464
@ConditionalOnClass(Http2Protocol.class)
65-
WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
66-
@Value("${" + PREFIX + ".max-concurrent-streams:2147483647}") int maxConcurrentStreams) {
65+
@ConditionalOnProperty(prefix = PREFIX, name = "max-concurrent-streams")
66+
public WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
67+
@Value("${" + PREFIX + ".max-concurrent-streams}") int maxConcurrentStreams) {
6768
return factory -> factory.addConnectorCustomizers(connector -> {
6869
ProtocolHandler handler = connector.getProtocolHandler();
6970
for (UpgradeProtocol upgradeProtocol : handler.findUpgradeProtocols()) {
7071
if (upgradeProtocol instanceof Http2Protocol) {
7172
Http2Protocol protocol = (Http2Protocol) upgradeProtocol;
72-
protocol.setMaxConcurrentStreams(maxConcurrentStreams);
73-
protocol.setMaxConcurrentStreamExecution(maxConcurrentStreams);
73+
int value = maxConcurrentStreams < 0 ? Integer.MAX_VALUE : maxConcurrentStreams;
74+
protocol.setMaxConcurrentStreams(value);
75+
protocol.setMaxConcurrentStreamExecution(value);
7476
}
7577
}
7678
});

dubbo-spring-boot/dubbo-spring-boot-autoconfigure/src/main/java/org/apache/dubbo/spring/boot/autoconfigure/DubboTripleAutoConfiguration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class DubboTripleAutoConfiguration {
4545
@Configuration(proxyBeanMethods = false)
4646
@ConditionalOnClass(Filter.class)
4747
@ConditionalOnWebApplication(type = Type.SERVLET)
48-
@ConditionalOnProperty(prefix = PREFIX, name = "enabled")
48+
@ConditionalOnProperty(prefix = PREFIX, name = "enabled", havingValue = "true")
4949
public static class TripleServletConfiguration {
5050

5151
@Bean
@@ -63,15 +63,17 @@ public FilterRegistrationBean<TripleFilter> tripleProtocolFilter(
6363

6464
@Bean
6565
@ConditionalOnClass(Http2Protocol.class)
66-
WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
67-
@Value("${" + PREFIX + ".max-concurrent-streams:2147483647}") int maxConcurrentStreams) {
66+
@ConditionalOnProperty(prefix = PREFIX, name = "max-concurrent-streams")
67+
public WebServerFactoryCustomizer<ConfigurableTomcatWebServerFactory> tripleTomcatHttp2Customizer(
68+
@Value("${" + PREFIX + ".max-concurrent-streams}") int maxConcurrentStreams) {
6869
return factory -> factory.addConnectorCustomizers(connector -> {
6970
ProtocolHandler handler = connector.getProtocolHandler();
7071
for (UpgradeProtocol upgradeProtocol : handler.findUpgradeProtocols()) {
7172
if (upgradeProtocol instanceof Http2Protocol) {
7273
Http2Protocol protocol = (Http2Protocol) upgradeProtocol;
73-
protocol.setMaxConcurrentStreams(maxConcurrentStreams);
74-
protocol.setMaxConcurrentStreamExecution(maxConcurrentStreams);
74+
int value = maxConcurrentStreams < 0 ? Integer.MAX_VALUE : maxConcurrentStreams;
75+
protocol.setMaxConcurrentStreams(value);
76+
protocol.setMaxConcurrentStreamExecution(value);
7577
}
7678
}
7779
});

0 commit comments

Comments
 (0)