Skip to content

Commit 8577718

Browse files
committed
Close InputStream when loading PEM content from a resource
Fixes gh-44443
1 parent 8874582 commit 8577718

File tree

1 file changed

+3
-3
lines changed
  • spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem

1 file changed

+3
-3
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ssl/pem/PemContent.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -118,8 +118,8 @@ static PemContent load(String content, ResourceLoader resourceLoader) throws IOE
118118
if (isPresentInText(content)) {
119119
return new PemContent(content);
120120
}
121-
try {
122-
return load(resourceLoader.getResource(content).getInputStream());
121+
try (InputStream in = resourceLoader.getResource(content).getInputStream()) {
122+
return load(in);
123123
}
124124
catch (IOException | UncheckedIOException ex) {
125125
throw new IOException("Error reading certificate or key from file '%s'".formatted(content), ex);

0 commit comments

Comments
 (0)