Refactor: Tighten Logger, encapsulate Response.Builder, add HttpStatus, fix races#3469
Open
saikat709 wants to merge 5 commits into
Open
Refactor: Tighten Logger, encapsulate Response.Builder, add HttpStatus, fix races#3469saikat709 wants to merge 5 commits into
saikat709 wants to merge 5 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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