Repository navigation
Preserve non-UTF-8 container output - #12183
ZainnQureshii wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
An ISO-8859-1 container log line containing
cafécomes back ascaf�when read withfollowOutput()andToStringConsumer.toString(Charset), the path shown indocs/features/container_logs.md:58. The callback decodes and re-encodes each line as UTF-8 atcore/src/main/java/org/testcontainers/containers/output/FrameConsumerResultCallback.java:138beforeToStringConsumerapplies the requested charset atcore/src/main/java/org/testcontainers/containers/output/ToStringConsumer.java:33.Use a reversible ISO-8859-1 mapping for ANSI matching at
core/src/main/java/org/testcontainers/containers/output/FrameConsumerResultCallback.java:143and pass the original bytes through when color removal is disabled. Bytes outside the removed sequences reach the caller intact, so decoding the same line as ISO-8859-1 now returnscafé.Both
followOutput()overloads, snapshot and Compose logs, stdout and stderr inexecInContainer(Charset, ...), the log wait strategy, and the Docker registry test helper use the same callback. The separate deprecatedLogToStringContainerCallbackreads an ASCII gateway address in production and has no caller-selected charset.Refs #6163
Testing
./gradlew --no-daemon --no-build-cache --no-scan --console=plain :testcontainers:test --tests org.testcontainers.containers.output.FrameConsumerResultCallbackTestexited 1 with the base callback. The callback turnedcaféintocaf�in both ISO-8859-1 cases. Restoring the UTF-8 conversion only when color removal is disabled made just the new test fail, also with exit 1../gradlew --no-daemon --no-build-cache --no-scan --no-watch-fs --console=plain --max-workers=4 --continue --parallel -Porg.gradle.java.installations.fromEnv=TC_JDK11 checkstyleMain checkstyleTest spotlessCheckexited 0 for the root Gradle build. Gradle ran on Temurin 17.0.21 withTC_JDK11pointing to Temurin 11.0.33 for HiveMQ's test compilation../gradlew --no-daemon --no-build-cache --no-scan --console=plain --max-workers=4 --continue :testcontainers:check :testcontainers:test --tests org.testcontainers.containers.output.FrameConsumerResultCallbackTestexited 0. All 14 callback tests passed, including the ISO-8859-1 cases with ANSI colors removed and retained. The core check also ran Checkstyle, Spotless, Javadoc,japicmp, and the shaded JAR tests. The JAR tests reported 663 passed and 15 skipped by the API suite's assumptions.The
:testcontainers:testfilter selected the in-memory callback tests to verify the fix without a Docker daemon. It excluded the other core test classes, including Docker-backed integration tests.Prepared with AI assistance (Codex and Claude Code) and reviewed with GitHub Copilot.
🤖 Generated with Claude Code
Summary by CodeRabbit
café, is now preserved when ANSI color codes are removed or retained. This prevents character corruption during output processing while keeping the requested color-code behavior unchanged.