This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit 7389ef82964130cd34e44da2a6e6f03b6d195ab5 Author: Claus Ibsen <[email protected]> AuthorDate: Sun Jan 8 21:01:54 2023 +0100 Close stream --- .../main/java/org/apache/camel/component/RepositoryFactory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java b/components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java index 2950415e39a..83c94adfb7f 100644 --- a/components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java +++ b/components/camel-git/src/main/java/org/apache/camel/component/RepositoryFactory.java @@ -30,6 +30,7 @@ import java.util.List; import org.apache.camel.RuntimeCamelException; import org.apache.camel.component.git.GitEndpoint; import org.apache.camel.support.ResourceHelper; +import org.apache.camel.util.IOHelper; import org.apache.camel.util.ObjectHelper; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; @@ -106,8 +107,12 @@ public abstract class RepositoryFactory { private static File getTempFileFromHttp(String url) throws IOException { Path tempFile = Files.createTempFile(null, null); FileOutputStream outputStream = new FileOutputStream(tempFile.toString()); - ReadableByteChannel byteChannel = Channels.newChannel(new URL(url).openStream()); - outputStream.getChannel().transferFrom(byteChannel, 0, Long.MAX_VALUE); + try { + ReadableByteChannel byteChannel = Channels.newChannel(new URL(url).openStream()); + outputStream.getChannel().transferFrom(byteChannel, 0, Long.MAX_VALUE); + } finally { + IOHelper.close(outputStream); + } return tempFile.toFile(); }
