Ignore non-jar files in ServiceLoaderLite (KT-29513)
This commit is contained in:
@@ -71,7 +71,7 @@ object ServiceLoaderLite {
|
||||
|
||||
return when {
|
||||
file.isDirectory -> findImplementationsInDirectory(classIdentifier, file)
|
||||
file.isFile -> findImplementationsInJar(classIdentifier, file)
|
||||
file.isFile && file.extension.toLowerCase() == "jar" -> findImplementationsInJar(classIdentifier, file)
|
||||
else -> emptySet()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ abstract class AbstractServiceLoaderLiteTest : TestCaseWithTmpdir() {
|
||||
}
|
||||
|
||||
protected fun writeJar(fileName: String, vararg entries: Entry): File {
|
||||
val file = File(tmpdir, fileName)
|
||||
val file = File(tmpdir, "$fileName.jar")
|
||||
if (file.exists()) {
|
||||
throw IllegalStateException("File $fileName already exists")
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.cli.serviceLoaderLite
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite
|
||||
import org.jetbrains.kotlin.cli.jvm.plugins.ServiceLoaderLite.ServiceLoadingException
|
||||
import java.io.File
|
||||
import javax.annotation.processing.Processor
|
||||
|
||||
class ServiceLoaderLiteTest : AbstractServiceLoaderLiteTest() {
|
||||
@@ -112,5 +113,11 @@ class ServiceLoaderLiteTest : AbstractServiceLoaderLiteTest() {
|
||||
assertTrue("test.Zoo" in impls)
|
||||
}
|
||||
}
|
||||
|
||||
fun testWrongJarName() {
|
||||
val file = File(tmpdir, "foo.tar.gz")
|
||||
file.writeText("foobar")
|
||||
ServiceLoaderLite.findImplementations(Processor::class.java, listOf(file))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user