This commit added a guard against invalid characters in SSE. It triggers null pointer exceptions when null values are used in id and event properties:
java.lang.NullPointerException: Cannot invoke "String.indexOf(int)" because "content" is null
at org.springframework.http.codec.ServerSentEvent$BuilderImpl.checkEvent(ServerSentEvent.java:270)
Suppressed: The stacktrace has been enhanced by Reactor, refer to additional information below:
Original Stack Trace:
at org.springframework.http.codec.ServerSentEvent$BuilderImpl.checkEvent(ServerSentEvent.java:270)
at org.springframework.http.codec.ServerSentEvent$BuilderImpl.id(ServerSentEvent.java:257)
at io.modelcontextprotocol.server.transport.WebFluxStreamableServerTransportProvider$WebFluxStreamableMcpSessionTransport.lambda$sendMessage$1(WebFluxStreamableServerTransportProvider.java:361)
at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:196)
These properties are marked as @Nullable so it should be possible to use null values in the builder.
I came across this issue after updating spring-web to 6.2.17, before that I was using 6.2.10 without any problems.
For context, I have a Spring-AI-based MCP server with streamable HTTP transport (spring-ai:1.1.4). Spring AI 2.x introduced a fix on their end, but for those stuck with 1.x for now, so the workaround is to use SSE transport instead of streamable HTTP.
This commit added a guard against invalid characters in SSE. It triggers null pointer exceptions when null values are used in
idandeventproperties:These properties are marked as
@Nullableso it should be possible to use null values in the builder.I came across this issue after updating
spring-webto6.2.17, before that I was using6.2.10without any problems.For context, I have a Spring-AI-based MCP server with streamable HTTP transport (
spring-ai:1.1.4). Spring AI 2.x introduced a fix on their end, but for those stuck with 1.x for now, so the workaround is to use SSE transport instead of streamable HTTP.