Skip to content

[Fix] Make WebSocket ServerEndpointExporter conditional to avoid ServerContainer not available - #4501

Open
zhang-arvin wants to merge 1 commit into
apache:devfrom
zhang-arvin:fix/3907-websocket-servercontainer
Open

[Fix] Make WebSocket ServerEndpointExporter conditional to avoid ServerContainer not available#4501
zhang-arvin wants to merge 1 commit into
apache:devfrom
zhang-arvin:fix/3907-websocket-servercontainer

Conversation

@zhang-arvin

Copy link
Copy Markdown

What changes were proposed in this pull request

Make the WebSocket ServerEndpointExporter bean conditional on the websocket.enabled property (default: true), so that the application can start gracefully when the javax.websocket.server.ServerContainer is not available.

Why are the changes needed?

When flink-shaded-hadoop-3-uber jar is placed in the lib/ directory, it conflicts with the embedded server's WebSocket implementation, causing the ServerContainer to be unavailable. This results in the application failing to start with:

java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

This fix makes the WebSocket support optional, allowing users to disable WebSocket by setting websocket.enabled=false when they encounter classpath conflicts.

Fix: #3907

How was this patch tested?

  • Manual verification: The @ConditionalOnProperty annotation is a standard Spring Boot mechanism that is widely used in the project.
  • The existing behavior is preserved: when websocket.enabled is not set (or set to true), the ServerEndpointExporter bean is created as before.
  • When websocket.enabled=false, the bean is not created, and the application starts without WebSocket support. The MessageServiceImpl.push() method already handles the case where WebSocket is unavailable via try-catch.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Websocket serverContainer not available

1 participant