Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exceptionHandler of AsyncFile is not triggered #5343

Open
d-william opened this issue Oct 4, 2024 · 2 comments
Open

exceptionHandler of AsyncFile is not triggered #5343

d-william opened this issue Oct 4, 2024 · 2 comments
Labels

Comments

@d-william
Copy link

Version

Vert.x core : 4.5.10

Context

The exceptionHandler of an AsyncFile is not triggered when an exception is thrown in the data handler (when read).

Do you have a reproducer?

FileSystem files = Vertx.vertx().fileSystem();
Future<AsyncFile> open = files.open("file.txt", new OpenOptions());
open.onSuccess(file -> {
    file.exceptionHandler(error -> {
        System.out.println("Error: " + error.getMessage());
    });
    file.handler(buffer -> {
        System.out.println("Read data: " + buffer.toString());
        throw new RuntimeException("Error");
    });
});

Here, "Error: Error" is not displayed

Some behavior if an exception is thrown in the end handler

file.endHandler(v -> {
    System.out.println("End of file");
    throw new RuntimeException("error");
});

Extra

  • Dev hint : Register an exception handler in the internal InboundBuffer of AsyncFileImpl
@d-william d-william added the bug label Oct 4, 2024
@d-william
Copy link
Author

It seems expected ?
Because the same behavior happens with MessageConsumer see
But at least the exception is throw in the context : "ERROR io.vertx.core.impl.ContextImpl - Unhandled exception"
Perhaps the same approach is needed for AsyncFile ?

Also maybe a clarfication in the javadoc will be nice.
In InboundBuffer, which have methods with same names (exceptionHandler and handler) the exceptionHandler is called when there is an error in the handler

@vietj
Copy link
Member

vietj commented Oct 5, 2024

I think we should report the exception to the context indeed that would be the correct behavior

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants