ENT-6412: Upgrade ClassGraph 4.8.90 -> 4.8.135. (#6973)

This commit is contained in:
Chris Rankin 2021-11-23 09:43:41 +00:00 committed by GitHub
parent 18333b4860
commit e93e7c2846
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 11 deletions

View File

@ -21,7 +21,7 @@ jdkClassifier11=jdk11
dockerJavaVersion=3.2.5
proguardVersion=6.1.1
bouncycastleVersion=1.68
classgraphVersion=4.8.90
classgraphVersion=4.8.135
disruptorVersion=3.4.2
typesafeConfigVersion=1.3.4
jsr305Version=3.0.2

View File

@ -11,9 +11,9 @@ import kotlin.concurrent.withLock
private val pooledScanMutex = ReentrantLock()
/**
* Use this rather than the built in implementation of [scan] on [ClassGraph]. The built in implementation of [scan] creates
* a thread pool every time resulting in too many threads. This one uses a mutex to restrict concurrency.
* Use this rather than the built-in implementation of [ClassGraph.scan]. The built-in implementation creates
* a thread pool every time, resulting in too many threads. This one uses a mutex to restrict concurrency.
*/
fun ClassGraph.pooledScan(): ScanResult {
return pooledScanMutex.withLock { this@pooledScan.scan() }
return pooledScanMutex.withLock(::scan)
}

View File

@ -1,6 +1,5 @@
package net.corda.serialization.reproduction;
import com.google.common.io.LineProcessor;
import net.corda.client.rpc.CordaRPCClient;
import net.corda.core.concurrent.CordaFuture;
import net.corda.node.services.Permissions;

View File

@ -123,7 +123,10 @@ class CordaServiceTest {
val identityService = makeTestIdentityService(dummyNotary.identity)
Assertions.assertThatThrownBy { MockServices(cordappPackages, dummyNotary, identityService, dummyCashIssuer.keyPair, bankOfCorda.keyPair) }
.isInstanceOf(ClassNotFoundException::class.java).hasMessage("Could not create jar file as the given package is not found on the classpath: com.r3.corda.sdk.tokens.money")
.isInstanceOf(ClassNotFoundException::class.java)
.hasMessageStartingWith("Could not create jar file as ")
.hasMessageContaining("com.r3.corda.sdk.tokens.money")
.hasMessageEndingWith(" not found on the classpath")
}
@StartableByService

View File

@ -59,6 +59,12 @@ data class CustomCordapp(
}
classGraph.enableClassInfo().pooledScan().use { scanResult ->
if (scanResult.allResources.isEmpty()) {
throw ClassNotFoundException(
"Could not create jar file as the given classes(${classes.joinToString()}) / packages(${packages.joinToString()}) were not found on the classpath"
)
}
val whitelistService = SerializationWhitelist::class.java.name
val whitelists = scanResult.getClassesImplementing(whitelistService)
@ -73,13 +79,9 @@ data class CustomCordapp(
}
}
if (scanResult.allResources.isEmpty()){
throw ClassNotFoundException("Could not create jar file as the given package is not found on the classpath: ${packages.toList()[0]}")
}
// The same resource may be found in different locations (this will happen when running from gradle) so just
// pick the first one found.
scanResult.allResources.asMap().forEach { path, resourceList ->
scanResult.allResourcesAsMap.forEach { (path, resourceList) ->
jos.addEntry(testEntry(path), resourceList[0].open())
}
}