Skip to content

[Backport release-1.17] feat: add DaprClient.invokeHttpClient(appId) factory#1763

Merged
cicoyle merged 2 commits into
release-1.17from
backport-1742-to-release-1.17
Jun 9, 2026
Merged

[Backport release-1.17] feat: add DaprClient.invokeHttpClient(appId) factory#1763
cicoyle merged 2 commits into
release-1.17from
backport-1742-to-release-1.17

Conversation

@dapr-bot

@dapr-bot dapr-bot commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Backport 9539d70 from #1742.

* chore: rewrite invoke/http example to use native HttpClient

The DaprClient.invokeMethod wrappers were deprecated by #1666. Rewrite
the invoke/http sample to use java.net.http.HttpClient through the Dapr
sidecar, demonstrating both URL forms accepted by the sidecar — the
dapr-app-id header against the sidecar base URL, and the explicit
/v1.0/invoke/<app-id>/method/<method> path.

Update the matching README snippet and reduce expected_stdout_lines to
'Done' — the previous expected lines never matched what DemoService
returns (a timestamp).

Signed-off-by: Javier Aliaga <javier@diagrid.io>

* feat: add DaprClient.invokeHttpClient(appId) factory

Provides an SDK-native successor to the invokeMethod APIs deprecated by
#1666. DaprClient.invokeHttpClient(appId) returns a DaprInvokeHttpClient
pre-bound to {daprHttpEndpoint}/v1.0/invoke/{appId}/method/ that reuses
the SDK's shared java.net.http.HttpClient and attaches the dapr-api-token
header when configured.

Update the invoke/http example and README to demonstrate the new helper
alongside the raw dapr-app-id header form.

Signed-off-by: Javier Aliaga <javier@diagrid.io>

* feat: add DaprBodyPublishers.json helper and invokeHttpClient migration notes

Adds an opt-in DaprBodyPublishers.json(Object) helper backed by the SDK's
default Jackson serializer, matching the JSON encoding the deprecated
DaprClient.invokeMethod APIs applied internally. Eases migration without
re-introducing auto-serialization into the raw HttpClient surface exposed
by invokeHttpClient.

Also fixes the invoke/http example README expected_stdout_lines to match
the new plain-text body sent by the refactored example (Server: message
one instead of Server: "message one"), and adds migration notes to the
DaprClient.invokeHttpClient and DaprInvokeHttpClient Javadoc as well as
the example README.

Signed-off-by: Javier Aliaga <javier@diagrid.io>

---------

Signed-off-by: Javier Aliaga <javier@diagrid.io>
(cherry picked from commit 9539d70)
@dapr-bot dapr-bot requested review from a team as code owners June 8, 2026 15:42
@javier-aliaga javier-aliaga reopened this Jun 9, 2026
Signed-off-by: Javier Aliaga <javier@diagrid.io>
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.97%. Comparing base (80687da) to head (a25e2ac).

Files with missing lines Patch % Lines
...c/main/java/io/dapr/client/DaprBodyPublishers.java 60.00% 2 Missing ⚠️
...t4/autoconfigure/client/ObservationDaprClient.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             release-1.17    #1763      +/-   ##
==================================================
+ Coverage           72.92%   72.97%   +0.05%     
- Complexity           2254     2276      +22     
==================================================
  Files                 241      243       +2     
  Lines                7401     7437      +36     
  Branches              736      739       +3     
==================================================
+ Hits                 5397     5427      +30     
- Misses               1645     1651       +6     
  Partials              359      359              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cicoyle cicoyle merged commit c02ab76 into release-1.17 Jun 9, 2026
19 of 21 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.

3 participants