Skip to content

fix: separate merged fatjar service providers - #2709

Open
gelatoni-xh wants to merge 1 commit into
jbangdev:mainfrom
gelatoni-xh:fix/2704-fatjar-service-newline
Open

gelatoni-xh wants to merge 1 commit into
jbangdev:mainfrom
gelatoni-xh:fix/2704-fatjar-service-newline

Conversation

@gelatoni-xh

@gelatoni-xh gelatoni-xh commented Nov 14, 2026 •

Copy link
Copy Markdown

Problem

jbang export fatjar appends duplicate META-INF/services/* entries byte-for-byte. If a provider file has no trailing newline, its last provider and the next file's first provider become one invalid class name.

Change

  • Write a newline before appending each subsequent service file. Blank lines are valid in service configuration files, so existing line endings remain intact.
  • Strengthen the export regression test to assert separate provider lines for files ending with no newline, LF, CRLF, or CR.

Fixes #2704.

Validation

  • Confirmed the new no-trailing-newline test fails before the fix with com.example.Impl1com.example.Impl2 on one line.
  • ./gradlew test --tests 'dev.jbang.cli.TestExport' formatCheck passed after the fix on the latest upstream main (29 tests passed, 3 skipped).
  • git diff --check passed.

The full unit and integration suites were not run locally.

The implementation and tests were prepared with AI assistance. The contributor discussed the fix approach and authorized this PR; human review of the final code and CI results is pending.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue in exported fat JARs where combining duplicate service-provider entries could join provider names when the existing entry had no trailing newline. Merged entries now keep providers separated across empty, LF, CRLF, and CR line-ending formats, helping ensure each provider remains available to applications using the exported archive.

@coderabbitai

coderabbitai Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Fatjar export now writes a newline before appending duplicate META-INF/services/ entries. The service-file merge test covers empty, LF, CRLF, and CR line endings and checks that both providers remain separate and ordered.

Changes: Service-file merge

Layer / File(s) Summary
Separate and validate merged providers
src/main/java/dev/jbang/cli/Export.java, src/test/java/dev/jbang/cli/TestExport.java
handleZipFile writes a newline before appending duplicate service-file contents. The parameterized test checks provider order for empty, LF, CRLF, and CR line endings. Both providers use UTF-8 in the test.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: stalep, maxandersen

Merge Risk: Minimal · up to 6090c

Fatjar export now separates merged service provider entries, so a missing trailing newline no longer concatenates provider names. The change is small and tested for several line endings, and no merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the fix and the affected area: separating merged fatjar service providers. The change adds a newline before each appended META-INF/services/ entry in ExportFatjar.handleZipFile, which …
Linked Issues check Passed Directly linked issue #2704 requires a separator so appended META-INF/services/* providers cannot merge when a provider file lacks a trailing newline. The AI-generated summary of src/main/java/dev/jba…
Out of Scope Changes check Passed The changes touch two files: Export.java (newline separator in the fatjar service-file merge) and TestExport.java (service-file merge regression test). Both directly implement or verify issue #2704. T…
Full details: Title check

Explanation

The title names the fix and the affected area: separating merged fatjar service providers. The change adds a newline before each appended META-INF/services/ entry in ExportFatjar.handleZipFile, which keeps adjacent provider names from concatenating. The title is short, specific, and uses the conventional fix: prefix. It does not mention the newline mechanism or the test changes, which is acceptable because the title need not cover every detail.

Full details: Linked Issues check

Explanation

Directly linked issue #2704 requires a separator so appended META-INF/services/* providers cannot merge when a provider file lacks a trailing newline. The AI-generated summary of src/main/java/dev/jbang/cli/Export.java states that ExportFatjar.handleZipFile now writes a newline before appending each duplicate service entry (+2/-0). This matches the fix the issue suggests (ensure a newline between appended files). The test summary for src/test/java/dev/jbang/cli/TestExport.java states that the service-file merge test runs with empty, LF, CRLF, and CR endings and checks that both providers appear on separate lines. This covers the no-trailing-newline case from the issue example. The optional line-by-line trimming and deduplication in the issue is a suggestion ('Ideally'), not a stated requirement, and the PR does not claim it. Limitation: the repository diff tool returned no text for either changed file, and a file read of Export.java was truncated before handleZipFile. The code-level result therefore rests on the supplied summary and PR description, not on a direct read of the changed lines.

Full details: Out of Scope Changes check

Explanation

The changes touch two files: Export.java (newline separator in the fatjar service-file merge) and TestExport.java (service-file merge regression test). Both directly implement or verify issue #2704. The summary reports no changes to public or exported declarations. No unrelated changes appear in the supplied summary. Limitation: the diff tool could not return the text of either file, so the absence of other hunks rests on the supplied whole-PR summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between e5af0ea and 6090cd6.

Files selected for processing: 2

  • src/main/java/dev/jbang/cli/Export.java
  • src/test/java/dev/jbang/cli/TestExport.java

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

This branch has not been deployed

No deployments
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.

export fatjar: service-file merge concatenates providers without a newline separator

1 participant