From 0a9fe654431555dd36a4aa0f62a7ed386c86df40 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 23 Jan 2020 14:37:06 +0000 Subject: [PATCH] Use line endings on all OSs when writing image config JSON Previously \r\n was used on Windows and \n was used on other platforms. This resulted in different JSON content being written to the archive. As the config's entry name is the SHA-256 hash of its content, it also resulted in the entry name being different. This commit updates the JSON that's written into the archive to use \n line endings, irrespective of the OS on which the image is being built. See gh-19828 --- .../boot/buildpack/platform/docker/type/ImageArchive.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchive.java b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchive.java index 665bc18164..e9baf846bd 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchive.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchive.java @@ -136,7 +136,7 @@ public class ImageArchive implements TarArchive { private String writeConfig(Layout writer, List writtenLayers) throws IOException { try { ObjectNode config = createConfig(writtenLayers); - String json = this.objectMapper.writeValueAsString(config); + String json = this.objectMapper.writeValueAsString(config).replace("\r\n", "\n"); MessageDigest digest = MessageDigest.getInstance("SHA-256"); InspectedContent content = InspectedContent.of(Content.of(json), digest::update); String name = "/" + LayerId.ofSha256Digest(digest.digest()).getHash() + ".json";