Skip to content

Commit 0a9fe65

Browse files
committed
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
1 parent a0b4cde commit 0a9fe65

File tree

1 file changed

+1
-1
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type

1 file changed

+1
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/type/ImageArchive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private LayerId writeLayer(Layout writer, Layer layer) throws IOException {
136136
private String writeConfig(Layout writer, List<LayerId> writtenLayers) throws IOException {
137137
try {
138138
ObjectNode config = createConfig(writtenLayers);
139-
String json = this.objectMapper.writeValueAsString(config);
139+
String json = this.objectMapper.writeValueAsString(config).replace("\r\n", "\n");
140140
MessageDigest digest = MessageDigest.getInstance("SHA-256");
141141
InspectedContent content = InspectedContent.of(Content.of(json), digest::update);
142142
String name = "/" + LayerId.ofSha256Digest(digest.digest()).getHash() + ".json";

0 commit comments

Comments
 (0)