fix: Ensure async clients use a thread factory that SLF4J-logs on uncaught Errors#82
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #8178 by ensuring that uncaught exceptions in Apache HTTP async client threads are logged via SLF4J instead of being potentially swallowed when written to System.err. This improves debuggability when HTTP client threads fail due to JVM errors.
Key Changes:
- Introduced a new
LoggingThreadFactorythat wraps Apache'sDefaultThreadFactoryand sets an uncaught exception handler on all created threads - Updated both cached and non-cached HTTP client configurations in
RateLimitedClientto use the new thread factory - Added a public
getDefaultThreadFactory()method toHttpAsyncClientSupplierfor reusability
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/main/java/io/github/jeremylong/openvulnerability/client/HttpAsyncClientSupplier.java | Adds LoggingThreadFactory class with SLF4J-based uncaught exception handler and exposes it via getDefaultThreadFactory() method |
| src/main/java/io/github/jeremylong/openvulnerability/client/nvd/RateLimitedClient.java | Integrates the new thread factory into HTTP client builders for both cached and non-cached configurations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
95556a5 to
41c6119
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
|
I ran CoPilot several times already (as you can see above) and it keeps on generating new low value suggestions on every iteration that it didn't mention earlier. IMHO a bit of a waste of time after a while. |
|
Any chance of cutting a patch release with this in it, so can update within ODC? |
|
absolutely. |
Per dependency-check/DependencyCheck#8178 currently if the async http client threads die due to a JVM
Error[1], the errors can be swallowed, depending on what your application does withSystem.err.That can make the root cause of the later failures difficult to determine without enabling debug logging (or impossible if an application complete swallows System.err rather than redirecting it somewhere you can see).
This change alters the default Apache HTTPClient thread factory to define an uncaught exception handler which uses SLF4J like the rest of the library.
I've left the logs at
ERRORlevel, but arguably they are fatal, as they potentially leave the cached http clients in a broken state.[1] The HTTP Client Async IO workers catch and report
Exceptions, but notErrors: