eclipse-ee4j / eclipse-ee4j/jersey
ClientRuntime is catching Throwable and wrapping as an Exception
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
See for example: [https://github.com/jersey/jersey/blob/master/core-client/src/main/java/org/glassfish/jersey/client/ClientRuntime.java#L261](https://github.com/jersey/jersey/blob/master/core-client/src/main/java/org/glassfish/jersey/client/ClientRuntime.java#L261)
But I see several more just in that file.
We hit an OutOfMemoryError during the invoke method, but Jersey wrapped it as a ProcessingException, so we were not able to handle it properly (it was caught & logged by our catch(Exception) block, rather than gathering a heap dump and restarting the application). Now we are putting a hack in place to check the cause of any ProcessingException and look to see if it is an error and then rethrow it, but this is a silly workaround and not easy to maintain. When we write 'catch(Exception e)', we do not expect this to catch Error.
My suggestion is it should not catch an Error and wrap it as an Exception. Instead it should catch only Exception, and allow Errors to bubble up since they are typically fatal. Or perhaps have a separate ProcessingError class that extends from Error instead of Exception.
#### Affected Versions
[2.25]
Contributor guide
Assessment
This issue has not been assessed yet.