-
[NA] [BE] Upgrade Dropwizard to 5.0.0 with CORS and WireMock Jetty 12 compatibility (#3822)
发布于
2025-11-11 13:32:56 +00:00 - [NA] [BE] Refactor webhook async handling and resource management
-
WebhookSubscriber: Fixed 5 async/non-blocking issues
- Replaced Mono.fromRunnable with Mono.fromCallable for proper exception handling
- Wrapped blocking deserialization with Mono.fromCallable + subscribeOn
- Moved attributes building inside Mono chain
- Pre-built metrics counters to avoid repeated instantiation
- Added timeout and validated HTTP client usage
-
BaseRedisSubscriber: Added backpressure monitoring
- Added pre-built backpressure drop counter
- Logs when backpressure causes events to be dropped
- Helps identify system overload conditions
-
WebhookHttpClient: Major async/resource management improvements
- Async JSON serialization on boundedElastic scheduler
- Try-with-resources for automatic response cleanup
- Optional for null-safe string handling
- Retry attempt logging for observability
- Returns response body or 'ok' instead of exposing Response object
- No duplicate error logging
-
AlertService: Updated to work with new Mono return type
- Handles response body directly
- Defaults to 200 status code on success
All changes follow reactive best practices and enterprise-grade patterns.
-
Revision 2: Address all 8 GitHub PR comments - fix reactive chain, remove unnecessary wrappers, consolidate schedulers, fix resource management, and clarify logging messages
-
Revision 3: Use try-with-resources for cleaner Resource management in async callback
-
Revision 4: Simplify try-with-resources syntax using Java 9+ style
-
Revision 5: Address 4 new Copilot comments - use parallel() for CPU-bound JSON work, remove misleading comment, simplify validation with Mono.fromRunnable()
-
Revision 6: Keep boundedElastic() for JSON work - better migration path for future virtual threads
-
Revision 7: Use parallel() for short CPU-bound JSON work - not suitable for virtual threads
-
Revision 8: Use boundedElastic() consistently - project has virtual threads support (enableVirtualThreads flag) for future efficiency
-
[NA] [BE] Fix webhook async handling - restore original working structure with proper error handling
-
[NA] [BE] Upgrade Dropwizard to 5.0.0 with CORS and WireMock Jetty 12 compatibility
- Updated CorsFactory.java to use CrossOriginHandler instead of deprecated CrossOriginFilter
- Changed method name from registerFilterIfEnabled to registerHandlerIfEnabled
- Updated CORS configuration to use Set parameters for Jetty 12 compatibility
- Correctly mapped CHAIN_PREFLIGHT_PARAM=false to setDeliverPreflightRequests(false)
- Updated HttpModule.java to call the new registerHandlerIfEnabled method
- Added jetty-ee10-servlets dependency for Jetty 12 servlet support
- Replaced wiremock dependency with wiremock-jetty12 for Jetty 12 compatibility
- Updated WireMockUtils to use Jetty12HttpServerFactory from wiremock-jetty12 module
- All tests now pass with Dropwizard 5.0.0 and Jetty 12
- [NA] [BE] Fix String.format error in attachment upload test
- Changed uploadFile method to use externatClient instead of client
- This prevents String.format error when processing presigned URLs with % characters
- The externatClient is a regular JAX-RS ClientBuilder client that doesn't interpret % as format specifiers
- [NA] [BE] Fix String.format error in downloadFile method
- Changed downloadFile method to use externatClient instead of client
- This prevents String.format error when processing download URLs with % characters
- Both uploadFile and downloadFile now use externatClient for external URLs
Co-authored-by: Andres Cruz andresc@comet.com
下载附件