Merge pull request #51398 from dlwldn30

Closes gh-51398

* close-aot-file-content-stream:
  Polish "Release file handle when comparing AOT file content"
  Release file handle when comparing AOT file content
This commit is contained in:
Stéphane Nicoll
2026-08-24 08:07:49 +02:00
@@ -442,7 +442,7 @@ class SpringBootJoranConfigurator extends JoranConfigurator {
if (file.exists()) {
InputStreamSource content = file.getContent();
Assert.state(content != null, "Unable to get file content");
byte[] existingContent = content.getInputStream().readAllBytes();
byte[] existingContent = toByteArray(content);
if (!Arrays.equals(this.newContent, existingContent)) {
throw new IllegalStateException(
"Logging configuration differs from the configuration that has already been written. "
@@ -454,6 +454,12 @@ class SpringBootJoranConfigurator extends JoranConfigurator {
}
}
private byte[] toByteArray(InputStreamSource content) throws IOException {
try (InputStream inputStream = content.getInputStream()) {
return inputStream.readAllBytes();
}
}
}
}