mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 20:19:06 +00:00
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:
+7
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user