Refactor: Tighten Logger, encapsulate Response.Builder, add HttpStatus, fix races - #3469
Refactor: Tighten Logger, encapsulate Response.Builder, add HttpStatus, fix races#3469saikat709 wants to merge 5 commits into
Conversation
|
Thanks for the PR — the Builder encapsulation, deprecated-cleanup, and concurrency fixes are welcome. A few things are blocking merge as-is: Tests. The PR adds public API ( CancellableFuture is a partial fix. If
On Alternatively, splitting the Builder/race/deprecated-removal half into its own PR (with tests) would let that land quickly while the |
| * such and skipped. | ||
| */ | ||
| @SuppressWarnings("unused") | ||
| @Deprecated |
Adds a new top-level
HttpStatusenum covering the 19 status codes that s 0FeignExceptionrecognises and uses it to replace the literal400,401,403, …,504magic numbers in the fourteenFeignClientException/FeignServerExceptionsubclasses and in theclientErrorStatus/serverErrorStatusswitch statements. Also replaces the204/205literals in
Logger.logAndRebufferResponse. Switches now switch onHttpStatusconstants, so the status-to-exception mapping reads off theconstant names directly.
Four follow-ups in the same files:
Logger.Levelgets anatLeast(Level)helper. The fourlogLevel.ordinal() >= Level.X.ordinal()comparisons inlogRequest,logAndRebufferResponse, andlogIOExceptionbecomelogLevel.atLeast(Level.X).logAndRebufferResponsealso loses itsheader loop and body rebuffering into
logResponseHeaders(...)andrebufferBody(...)private helpers.Response.Builder's seven fields are nowprivate. TheResponse(Builder)constructor in the same file routes throughpackage-private getters, restoring the immutability contract the ╮
class javadoc already advertises.
Request.Options.getMethodOptions/setMethodOptionspreviouslyhad a check-then-act race on the
ConcurrentHashMap<String, Map<String, Options>>and used a plainHashMapfor the inner map. They now usecomputeIfAbsentand aConcurrentHashMapinner map.AsynchronousMethodHandler.CancellableFuture.inneris now anAtomicReference<CompletableFuture<T>>so retry callbacks no longerrace with
cancel().Request.Body.databecomesfinal; the no-argBody()constructor delegates tothis(null). ╮RequestTemplate.resolve(Map, Map)overload(
alreadyEncodedwas ignored) is removed. All in-repo callers usethe single-arg
resolve(Map).No public-API additions beyond
HttpStatusandLogger.Level#atLeast.japicmpis unchanged.$ ./mvnw -pl core test ╮
... Tests run: 634, Failures: 0, Errors: 0, Skipped: 3