Skip to content

35 split up serviceutils in generic and jdk http specific parts#64

Merged
tomsontom merged 8 commits into
mainfrom
35-split-up-serviceutils-in-generic-and-jdk-http-specific-parts
Jun 19, 2026
Merged

35 split up serviceutils in generic and jdk http specific parts#64
tomsontom merged 8 commits into
mainfrom
35-split-up-serviceutils-in-generic-and-jdk-http-specific-parts

Conversation

@tomsontom

Copy link
Copy Markdown
Member

No description provided.

@tomsontom tomsontom linked an issue Jun 19, 2026 that may be closed by this pull request

@tomsontom tomsontom left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Overview

Clean refactor that splits the monolithic ServiceUtils into two well-named classes:

  • BaseUtils — transport-agnostic: request body encoding, URL/ASCII encoding, URLSearchParams, toHeaders
  • JDKHttpClientResponseUtils — JDK HTTP client specific: response body parsing, error-response-to-string

The rename/split clearly communicates the responsibility of each class. The java-base/ location for the shared content generator is a good forward-looking structure.


Issues

Must Fix

1. Unused model parameter in generateBaseUtilsContent
packages/cli/src/java-base/base-utils.ts declares model: MResolvedRSDModel but never references it — the function only calls fqn() and returns a static toNodeTree(). Remove it from both the signature and the two call sites (generateBaseUtils in base-utils.ts and generator.ts).

2. Wrong config type in java-base/
generateBaseUtilsContent accepts JavaRestClientJDKGeneratorConfig but the only field it actually uses is rootPackageName. Placing a JDK-specific type in java-base/ (which is meant to be shared) ties the abstraction to one transport. Either narrow the argument to { rootPackageName: string } (or a shared base config type) or move the function into java-rest-client-jdk/.

Should Fix

3. Indentation inconsistency in generated BaseUtils.java
The template in java-base/base-utils.ts uses 4-space indentation inside the raw toNodeTree() template string, so the fixture BaseUtils.java is emitted with spaces. Every other generated file in this package (including the newly renamed JDKHttpClientResponseUtils.java) uses tabs. Align to tabs to match the project standard.

Minor

4. Missing newline at end of BaseUtils.java
The diff shows \ No newline at end of file. Trivial, but inconsistent.


Positive notes

  • The conceptual split is correct and well-executed.
  • All service impls are consistently updated — no stragglers left referencing ServiceUtils.
  • generator.ts wiring is clean; generateBaseUtils is appended at the right point.
  • Separating the 54%-similar response-utils.ts from the old service-utils.ts makes each file's purpose obvious.

@tomsontom tomsontom merged commit 89075ae into main Jun 19, 2026
2 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.

Split up ServiceUtils in Generic and JDK-HTTP-Specific parts

1 participant