close
Skip to content

Ignore invalid SSE retry field - #37193

Open
lArtiquel wants to merge 1 commit into
spring-projects:mainfrom
lArtiquel:sse-ignore-invalid-retry
Open

Ignore invalid SSE retry field#37193
lArtiquel wants to merge 1 commit into
spring-projects:mainfrom
lArtiquel:sse-ignore-invalid-retry

Conversation

@lArtiquel

Copy link
Copy Markdown

The SSE spec says a retry field must be ignored unless its value is only ASCII digits. ServerSentEventHttpMessageReader passes it straight to Long.parseLong, so one malformed field kills the whole stream:

retry:none
data:foo

NumberFormatException: For input string: "none"

Same for an empty retry: and for a value too large for a long. A client can't control what the server sends, so an unusable reconnection hint takes down an otherwise healthy subscription — and retry is a hint the reader never acts on itself.

This ignores the field in those cases. Test added; it fails before the change. spring-web and spring-webflux suites pass.

Per the SSE specification, a "retry" field whose value is not made up
solely of ASCII digits must be ignored. ServerSentEventHttpMessageReader
passed the value straight to Long.parseLong, so "retry:none", an empty
"retry:", or a value too large for a long raised NumberFormatException
and terminated the event stream. A client cannot control what a server
sends, so an unusable reconnection hint would kill an otherwise healthy
subscription.

Signed-off-by: Artyom Tsvirko <36863599+lArtiquel@users.noreply.github.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants