Skip to content

Report AsyncFile handler failures to the context - #6322

Open
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-5343-asyncfile-handler-exception
Open

Report AsyncFile handler failures to the context#6322
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:issue-5343-asyncfile-handler-exception

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #5343

Motivation

When the data handler or the end handler of an AsyncFile read stream throws, nothing happens: the InboundBuffer catches the throwable in handleEvent and, since AsyncFileImpl never registers an exception handler on its queue, the failure is silently dropped. Neither the stream exceptionHandler nor the context ever sees it (the issue's reproducer prints nothing).

As discussed on the issue, the correct behaviour is to report such failures to the context, like event-bus consumers do.

Changes

  • AsyncFileImpl.handleBuffer / handleEnd now dispatch the handler through the context (ContextInternal.dispatch), so an exception thrown by the handler is reported via Context.reportException (context exception handler → Vertx.exceptionHandler → "Unhandled exception" log). The stream exceptionHandler keeps its I/O failure semantic and is not invoked for a handler failure; reading is not interrupted and the end handler is still called.
  • Tests: FileSystemTest.testReadStreamHandlerExceptionReportedToContext / testReadStreamEndHandlerExceptionReportedToContext (fail without the change).

Note: NettyFileUpload (multipart uploads) has the same silent-swallow pattern with its InboundBuffer; left out of this PR since the issue is about AsyncFile, happy to address it here or separately if wanted.

When the data handler or the end handler of an AsyncFile read stream
throws, the exception is caught by the InboundBuffer and, since the file
does not register an exception handler on its queue, silently dropped.

Dispatch both handlers through the context so that such failures are
reported to the context exception handler, consistently with the other
Vert.x streams and event-bus consumers. The stream's exceptionHandler
keeps its I/O failure semantic and reading proceeds to the end handler.

Fixes eclipse-vertx#5343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant