Skip to content

Expose request elapsedTime to ResponseInterceptor via InvocationContext - #3690

Merged
velo merged 1 commit into
OpenFeign:masterfrom
Inf1mum:feat/2617-response-elapsed-time
Nov 16, 2026
Merged

velo merged 1 commit into
OpenFeign:masterfrom
Inf1mum:feat/2617-response-elapsed-time

Conversation

@Inf1mum

@Inf1mum Inf1mum commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Summary

ResponseHandler.handleResponse already receives the elapsed time of the request, but it was not passed into the InvocationContext handed to the ResponseInterceptor chain, so interceptor implementations could not report how long a request took.

This PR adds an elapsedTime field and a public elapsedTime() accessor to InvocationContext, populated from ResponseHandler. The async path (AsyncResponseHandler) delegates to ResponseHandler, so it is covered by the same change.

The change is purely additive for the public API: the new accessor is a new public method, and the touched constructors are package-private, so japicmp binary/source compatibility is unaffected.

Fixes #2617

Verification

Local verification ran on a host with JDK 21 only (no Docker):

  • mvn -pl core -Pdev test -Dtoolchain.skip=true: the toolchain profile is skipped as intended, and the main sources (including the touched classes) compile successfully. Test compilation cannot run on this host: default-testCompile is pinned to ${latest.java.version} (25) and existing core test sources use Java 22+ unnamed-variable syntax, so javac from JDK 21 rejects them. As a result the core test suite did not execute locally.
  • Fallback verification, as required in that situation:
    • The touched classes (InvocationContext.java, ResponseHandler.java) were compiled with javac -source 8 -target 8 against the core module classpath — clean.
    • A standalone runtime harness (real Feign.Builder client against MockWebServer with a capturing ResponseInterceptor) was compiled and run on JDK 21 against the rebuilt classes — the interceptor observed elapsedTime (e.g. 33 ms) and the response still decoded correctly.

Everything else is deferred to CI on JDK 25: the full core test suite (including the new FeignTest.responseInterceptorSeesElapsedTime test), japicmp compatibility gate, license header check (the local run also needed -Dlicense.skip=true because the license plugin's jgit scan fails on linked git worktrees), and google-java-format enforcement.

ResponseHandler.handleResponse already receives the elapsed time of the
request but did not pass it into the InvocationContext handed to the
ResponseInterceptor chain. Add an elapsedTime field with a public
elapsedTime() accessor to InvocationContext and populate it from
ResponseHandler; the async path shares the same handler. Constructors
are package-private so the change is purely additive for the public API.

Fixes OpenFeign#2617

Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
@velo
velo enabled auto-merge (squash) November 16, 2026 10:55

@velo velo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - adding elapsedTime to InvocationContext via ResponseInterceptor is additive and doesn't change existing behavior.

@velo
velo merged commit 2a9d472 into OpenFeign:master Nov 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using ResponseInterceptor : add request execution elapsedTime to the InvocationContext

2 participants