Skip to content

Commit ee12830

Browse files
gavinchouSivarajan Narayanan
andauthored
[fix](web) FE startup fail due to websocket startup (#62560)
## Summary Pick #60369 to branch-4.1 ## Changes - Fix FE startup failure when enable_https=true by using Spring Boot's addServerCustomizers() hook to initialize WebSocket support before WebAppContext starts - Compatible with branch-4.1's existing HTTP header size configuration ## Test - [x] FE build passed ## Related Issue close #60366 Co-authored-by: Sivarajan Narayanan <narayanan_sivarajan@apple.com>
1 parent 925840d commit ee12830

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

fe/fe-core/src/main/java/org/apache/doris/httpv2/config/WebServerFactoryCustomizerConfig.java

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919

2020
import org.apache.doris.common.Config;
2121

22+
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
24+
import org.eclipse.jetty.ee10.webapp.WebAppContext;
25+
import org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer;
2226
import org.eclipse.jetty.server.HttpConfiguration;
2327
import org.eclipse.jetty.server.HttpConnectionFactory;
2428
import org.eclipse.jetty.server.ServerConnector;
@@ -31,10 +35,24 @@
3135

3236
@Configuration
3337
public class WebServerFactoryCustomizerConfig implements WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> {
38+
private static final Logger LOG = LogManager.getLogger(WebServerFactoryCustomizerConfig.class);
39+
3440
@Override
3541
public void customize(ConfigurableJettyWebServerFactory factory) {
3642

3743
// Set HTTP header size for all connectors
44+
((JettyServletWebServerFactory) factory).addServerCustomizers(server -> {
45+
WebAppContext context = server.getDescendant(WebAppContext.class);
46+
if (context != null) {
47+
try {
48+
JettyWebSocketServletContainerInitializer.configure(context, null);
49+
} catch (Exception e) {
50+
LOG.error("Failed to initialize WebSocket support", e);
51+
throw new RuntimeException("Failed to initialize WebSocket support", e);
52+
}
53+
}
54+
});
55+
3856
factory.addServerCustomizers(server -> {
3957
for (org.eclipse.jetty.server.Connector connector : server.getConnectors()) {
4058
if (connector instanceof ServerConnector) {
@@ -53,19 +71,18 @@ public void customize(ConfigurableJettyWebServerFactory factory) {
5371
Collections.singletonList(new HttpToHttpsJettyConfig())
5472
);
5573

56-
factory.addServerCustomizers(
57-
server -> {
58-
HttpConfiguration httpConfiguration = new HttpConfiguration();
59-
httpConfiguration.setSecurePort(Config.https_port);
60-
httpConfiguration.setSecureScheme("https");
61-
62-
ServerConnector connector = new ServerConnector(server);
63-
connector.addConnectionFactory(new HttpConnectionFactory(httpConfiguration));
64-
connector.setPort(Config.http_port);
65-
66-
server.addConnector(connector);
74+
factory.addServerCustomizers(server -> {
75+
if (server.getConnectors() != null && server.getConnectors().length > 0) {
76+
ServerConnector existingConnector = (ServerConnector) server.getConnectors()[0];
77+
HttpConnectionFactory httpFactory =
78+
existingConnector.getConnectionFactory(HttpConnectionFactory.class);
79+
if (httpFactory != null) {
80+
HttpConfiguration httpConfig = httpFactory.getHttpConfiguration();
81+
httpConfig.setSecurePort(Config.https_port);
82+
httpConfig.setSecureScheme("https");
6783
}
68-
);
84+
}
85+
});
6986
}
7087
}
7188
}

0 commit comments

Comments
 (0)