From c53ea9dde5d888334f9ca3466ec36bcf90e4f9f6 Mon Sep 17 00:00:00 2001 From: Viktor Kolomeyko Date: Tue, 17 Jul 2018 09:04:24 +0100 Subject: [PATCH] Eliminate extensive printout when Byteman not found on the classpath. (#1277) Byteman is absent for most of the integration tests and long stacktrace is seen in the log presently that un-necessarily attracts attention and consumes logging space. (cherry picked from commit 2b6e59e7bd6c546aa5f78f97cb652c1f3122b89f) --- .../net/corda/testing/node/internal/DriverDSLImpl.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt index cda2d6af4d..6dc0ff9cf6 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt @@ -127,7 +127,7 @@ class DriverDSLImpl( private val quasarJarPath: String by lazy { resolveJar(".*quasar.*\\.jar$").getOrThrow() } private val bytemanJarPath: String? by lazy { - val maybeResolvedJar = resolveJar(".*byteman-\\d.*\\.jar$") + val maybeResolvedJar = resolveJar(".*byteman-\\d.*\\.jar$", verbose = false) when (maybeResolvedJar) { is Try.Success -> maybeResolvedJar.getOrThrow() is Try.Failure -> null @@ -144,7 +144,7 @@ class DriverDSLImpl( } } - private fun resolveJar(jarNamePattern: String): Try { + private fun resolveJar(jarNamePattern: String, verbose: Boolean = true): Try { return try { val cl = ClassLoader.getSystemClassLoader() val urls = (cl as URLClassLoader).urLs @@ -152,7 +152,11 @@ class DriverDSLImpl( val jarFileUrl = urls.first { jarPattern.matches(it.path) } Try.Success(jarFileUrl.toPath().toString()) } catch (e: Exception) { - log.warn("Unable to locate JAR `$jarNamePattern` on classpath: ${e.message}", e) + if(verbose) { + log.warn("Unable to locate JAR `$jarNamePattern` on classpath: ${e.message}", e) + } else { + log.info("Unable to locate JAR `$jarNamePattern` on classpath") + } Try.Failure(e) } }