From 34c174ca74d69f0d7c187beba4bd2133895c2d3d Mon Sep 17 00:00:00 2001 From: Aaron Siegel <2014957+aaron-siegel@users.noreply.github.com> Date: Fri, 8 Oct 2021 11:00:57 -0700 Subject: [PATCH] Fix minor initialization bug --- .../org/cgsuite/lang/CgscriptClasspath.scala | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/core/src/main/scala/org/cgsuite/lang/CgscriptClasspath.scala b/lib/core/src/main/scala/org/cgsuite/lang/CgscriptClasspath.scala index 50cb4fec..8892ef2f 100644 --- a/lib/core/src/main/scala/org/cgsuite/lang/CgscriptClasspath.scala +++ b/lib/core/src/main/scala/org/cgsuite/lang/CgscriptClasspath.scala @@ -1,5 +1,6 @@ package org.cgsuite.lang +import java.nio.file.FileSystemAlreadyExistsException import java.nio.file.spi.FileSystemProvider import java.util.Collections @@ -44,8 +45,12 @@ object CgscriptClasspath { // Search in the production jar. val uri = getClass.getResource("resources").toURI if (uri.getScheme == "jar") { - FileSystemProvider.installedProviders.asScala find { _.getScheme equalsIgnoreCase "jar" } foreach { provider => - provider.newFileSystem(uri, Collections.emptyMap[String, AnyRef]) + try { + FileSystemProvider.installedProviders.asScala find { _.getScheme equalsIgnoreCase "jar" } foreach { provider => + provider.newFileSystem(uri, Collections.emptyMap[String, AnyRef]) + } + } catch { + case _: FileSystemAlreadyExistsException => } } File(getClass.getResource("resources").toURI) @@ -85,8 +90,12 @@ object CgscriptClasspath { def copyExamples(dest: File): Unit = { val uri = getClass.getResource("examples").toURI if (uri.getScheme == "jar") { - FileSystemProvider.installedProviders.asScala find { _.getScheme equalsIgnoreCase "jar" } foreach { provider => - provider.newFileSystem(uri, Collections.emptyMap[String, AnyRef]) + try { + FileSystemProvider.installedProviders.asScala find { _.getScheme equalsIgnoreCase "jar" } foreach { provider => + provider.newFileSystem(uri, Collections.emptyMap[String, AnyRef]) + } + } catch { + case _: FileSystemAlreadyExistsException => } } val examplesDir = File(getClass.getResource("examples").toURI)