Skip to content

chore: dedupe pipeline call-state httpClient and reload/toBlocking#192

Merged
OmarAlJarrah merged 1 commit into
mainfrom
chore/pipeline-callstate-dedup
Jun 28, 2026
Merged

chore: dedupe pipeline call-state httpClient and reload/toBlocking#192
OmarAlJarrah merged 1 commit into
mainfrom
chore/pipeline-callstate-dedup

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

Behavior-preserving cleanups in the sdk-core HTTP pipeline runtime (org.dexpace.sdk.core.http.pipeline). No public-API or observable-behavior change; each item removes code that duplicates logic already living one call away.

Closes #171.

Changes

  • Drop the stored httpClient from PipelineCallState / AsyncPipelineCallState. The field was always the same instance as pipeline.httpClient — the cursor is only ever built from send/sendAsync (which pass their own client) and from copy (which forwards it). The sole readers, PipelineNext.process and AsyncPipelineNext.processAsync, now reach the client through pipeline, which removes the field, the constructor parameter, and one argument from every construction site. The async file also drops its now-unused AsyncHttpClient import.

  • reload() replays through append(). It previously re-implemented append()'s stage-dispatch loop verbatim. Since reload clears the pillar map first and a flattened list holds at most one pillar per stage, the pillar-replacement callback never fires during replay — bucketing policy now lives in one place.

  • build() uses List.toTypedArray() instead of the manual Array(size) { ordered[it] }, in both the sync and async builders. flatten() returns a non-null element list, so this yields the exact array type the constructors expect, empty case included.

  • toBlocking() delegates to AsyncHttpClient.asBlocking() rather than hand-rolling the identical blocking future.get() with interrupt handling (restore-flag → cancel(true)InterruptedIOException) and ExecutionException unwrapping. The cancellation contract now has a single definition.

  • Doc fix for Stage.order. The KDoc claimed the builder emits steps by reading the numeric order; it doesn't — flatten() walks Stage.entries (declaration order) and never consults order. The values happen to ascend with declaration order, which is why output stays sorted. Corrected the KDoc and the matching test comment so nobody tries to reorder steps by renumbering order. The order property is retained as a stable inspection key.

Verification

./gradlew :sdk-core:build passes — ktlint, detekt, allWarningsAsErrors, binary-compatibility check, tests, and the coverage gate. All changed declarations are internal or signature-unchanged, so there is no apiCheck impact.

Behavior-preserving cleanups in the http/pipeline runtime:

- Drop the stored httpClient from PipelineCallState / AsyncPipelineCallState.
  It was always the same instance as pipeline.httpClient; the sole readers
  (PipelineNext / AsyncPipelineNext) now reach it through pipeline, removing
  the field, the constructor parameter, and an argument at every call site.
- reload() now replays through append() instead of re-implementing the same
  stage-dispatch loop, keeping the bucketing policy in one place.
- build() materializes the ordered step list with List.toTypedArray() rather
  than a manual index-lambda Array(size){}.
- toBlocking() delegates to AsyncHttpClient.asBlocking() instead of hand-rolling
  the identical blocking-get with interrupt handling and ExecutionException
  unwrapping, leaving a single definition of the cancellation contract.
- Correct Stage.order's KDoc and a test comment: the builder emits in Stage
  declaration order (Stage.entries), not by reading the numeric order value.
@OmarAlJarrah OmarAlJarrah merged commit c1da824 into main Jun 28, 2026
1 check passed
@OmarAlJarrah OmarAlJarrah deleted the chore/pipeline-callstate-dedup branch June 28, 2026 01:31
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.

http/pipeline: drop redundant call-state httpClient and de-duplicate reload()/toBlocking()

1 participant