[minor] Fix URL conversion to the file
possibly fixes the exception from https://stackoverflow.com/questions/57727150/kotlin-script-engine-with-spring-boot-self-running-war
This commit is contained in:
+1
-1
@@ -52,7 +52,7 @@ class ClassPathTest : TestCase() {
|
||||
+ jar.toURI().toURL()).toTypedArray(),
|
||||
null
|
||||
)
|
||||
val cp = cl.classPathFromTypicalResourceUrls().toList()
|
||||
val cp = cl.classPathFromTypicalResourceUrls().toList().map { it.canonicalFile }
|
||||
|
||||
Assert.assertTrue(cp.contains(jar.canonicalFile))
|
||||
for (el in emulatedClasspath) {
|
||||
|
||||
@@ -94,10 +94,14 @@ fun tryGetResourcePathForClassByName(name: String, classLoader: ClassLoader): Fi
|
||||
|
||||
internal fun URL.toFileOrNull() =
|
||||
try {
|
||||
File(toURI().schemeSpecificPart).canonicalFile
|
||||
File(toURI())
|
||||
} catch (e: IllegalArgumentException) {
|
||||
null
|
||||
} catch (e: java.net.URISyntaxException) {
|
||||
null
|
||||
} ?: run {
|
||||
if (protocol != "file") null
|
||||
else File(file).canonicalFile
|
||||
else File(file)
|
||||
}
|
||||
|
||||
internal fun URL.toContainingJarOrNull(): File? =
|
||||
|
||||
Reference in New Issue
Block a user