-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
client: Allow AsyncContentListener.onContent to throw checked Exceptions #11800
Comments
The same would apply to Here, I see that the default implementation indeed catches the exception and just aborts the response. If so, that would be a strong argument for allowing these hooks to throw checked exceptions, such that the failure can be properly detected and forwarded to the source. Otherwise, I guess catching the exception and aborting the response manually could be acceptable as well. |
Signed-off-by: Ludovic Orban <[email protected]>
I've created a PR to modify the The fact that Thanks for the suggestion! |
Signed-off-by: Ludovic Orban <[email protected]>
Signed-off-by: Ludovic Orban <[email protected]>
…1825) #11800 allow ContentListener and AsyncContentListener to throw Exception Signed-off-by: Ludovic Orban <[email protected]>
Jetty version(s)
Jetty 12.x
Enhancement Description
AsyncContentListener
implementsContentSourceListener.onContentSource
and delegates to its own hook calledonContent
. Exceptions (or any Throwable really) thrown from onContent are catched and handled inside AsyncContentListener.onContentSource.Now I have an implementation of
AsyncContentListener.onContent
that writes the content to a file, which can fail with anIOException
. I would like to let these exceptions bubble up toonContentSource
, which would handle it nicely. But this is not possible sinceIOException
is a checked exception.There are two workarounds:
One is to wrap the
IOException
in aRuntimeException
and before rethrowing it.The other is to completely handle the exception myself, basically copying the
catch
block fromAsyncContentListener .onContentSource
.The text was updated successfully, but these errors were encountered: