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
The following commit(s) were added to refs/heads/main by this push: new 974c638 (chores) camel-maven-plugin: fix a possible leak when creating the filesystem (#6045) 974c638 is described below commit 974c638c3d877b5a140c5e1843393bede5e7f620 Author: Otavio Rodolfo Piske <orpi...@users.noreply.github.com> AuthorDate: Fri Sep 3 17:36:16 2021 +0200 (chores) camel-maven-plugin: fix a possible leak when creating the filesystem (#6045) --- .../java/org/apache/camel/maven/packaging/PackageJaxbMojo.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java index 6eee6c1..83f3919 100644 --- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java +++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/PackageJaxbMojo.java @@ -22,6 +22,7 @@ import java.io.IOError; import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.nio.file.FileSystem; import java.nio.file.FileSystemAlreadyExistsException; import java.nio.file.FileSystems; import java.nio.file.Files; @@ -153,11 +154,10 @@ public class PackageJaxbMojo extends AbstractGeneratorMojo { private Path asFolder(String p) { if (p.endsWith(".jar")) { File fp = new File(p); - try { - Map<String, String> env = new HashMap<>(); - return FileSystems.newFileSystem(URI.create("jar:" + fp.toURI().toString()), env).getPath("/"); + try (FileSystem fs = FileSystems.newFileSystem(URI.create("jar:" + fp.toURI()), new HashMap<>())) { + return fs.getPath("/"); } catch (FileSystemAlreadyExistsException e) { - return FileSystems.getFileSystem(URI.create("jar:" + fp.toURI().toString())).getPath("/"); + return FileSystems.getFileSystem(URI.create("jar:" + fp.toURI())).getPath("/"); } catch (IOException e) { throw new IOError(e); }