Skip to content

fix: Write manifests as UTF-8 and serialize the V3 manifest lazily - #1412

Open
ZPascal wants to merge 2 commits into
cloudfoundry:5.x.xfrom
ZPascal:fix-manifest-charset-and-errors
Open

ZPascal wants to merge 2 commits into
cloudfoundry:5.x.xfrom
ZPascal:fix-manifest-charset-and-errors

Conversation

@ZPascal

@ZPascal ZPascal commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1411.

This fixes the three manifest handling problems from the issue.

1. Manifests are written as UTF-8

ApplicationManifestUtils.write(OutputStream, ...) and ApplicationManifestUtilsV3.write(OutputStream, ...) now use new OutputStreamWriter(out, StandardCharsets.UTF_8) instead of the platform default charset. I added testWriteUsesUtf8 for this. I checked that it fails on the old code when the JVM runs with -Dfile.encoding=ISO-8859-1 and passes with the fix.

2. pushManifestV3 serializes the manifest lazily

Serialization now happens in a small serializeManifest helper that returns Mono.fromCallable(...). That Mono is zipped together with the client and space ID. If writing the manifest fails, the caller gets the error through the returned Mono instead of an exception thrown when the method is called. Everything else in the chain is unchanged.

3. Tests no longer leave files in /tmp

ApplicationManifestUtilsTest and ApplicationManifestUtilsV3Test now use JUnit's @TempDir instead of Files.createTempFile.

Testing

  • ApplicationManifestUtilsTest, ApplicationManifestUtilsV3Test and DefaultApplicationsTest pass locally on JDK 11 (150 tests, 2 skipped; those two were already skipped before this change).
  • ./mvnw spotless:check -Pintegration-test passes.

Note: #1410 also changes pushManifestV3, so whichever PR goes in second will need a small rebase.

- ApplicationManifestUtils and ApplicationManifestUtilsV3 now write
  manifests as UTF-8 instead of the platform default charset.
- pushManifestV3 serializes the manifest inside the Mono, so failures
  go through the reactive error channel instead of being thrown when
  the method is called.
- The manifest tests use @tempdir instead of leaving files in the
  system temp directory.

Fixes cloudfoundry#1411
@ZPascal
ZPascal force-pushed the fix-manifest-charset-and-errors branch from c86796c to cab275e Compare November 23, 2026 12:29
- Open manifest files with TRUNCATE_EXISTING so overwriting a longer
  file no longer leaves trailing bytes behind (V2 and V3)
- Flush instead of closing the caller-supplied OutputStream in
  write(OutputStream, ...) and document the UTF-8 output
- Serialize the V3 manifest before resolving the space and add
  OperationsLogging and a checkpoint to pushManifestV3
- Add tests for truncation, stream handling, V2 UTF-8 output and
  lazy pushManifestV3 assembly

@Test
void testWriteDoesNotCloseStream() {
boolean[] closed = {false};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why are you using an array here?

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.

2 participants