Skip to content

Commit

Permalink
Close InputStream when loading PEM content from a resource
Browse files Browse the repository at this point in the history
Fixes gh-44443
  • Loading branch information
wilkinsona committed Feb 26, 2025
1 parent 8874582 commit 8577718
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -118,8 +118,8 @@ static PemContent load(String content, ResourceLoader resourceLoader) throws IOE
if (isPresentInText(content)) {
return new PemContent(content);
}
try {
return load(resourceLoader.getResource(content).getInputStream());
try (InputStream in = resourceLoader.getResource(content).getInputStream()) {
return load(in);
}
catch (IOException | UncheckedIOException ex) {
throw new IOException("Error reading certificate or key from file '%s'".formatted(content), ex);
Expand Down

0 comments on commit 8577718

Please sign in to comment.