diff --git a/common/logging/src/main/kotlin/net/corda/common/logging/ExceptionsErrorCodeFunctions.kt b/common/logging/src/main/kotlin/net/corda/common/logging/ExceptionsErrorCodeFunctions.kt index 3064fce1cc..2304b164d0 100644 --- a/common/logging/src/main/kotlin/net/corda/common/logging/ExceptionsErrorCodeFunctions.kt +++ b/common/logging/src/main/kotlin/net/corda/common/logging/ExceptionsErrorCodeFunctions.kt @@ -1,7 +1,5 @@ package net.corda.common.logging -import org.apache.logging.log4j.Level -import org.apache.logging.log4j.message.Message import org.apache.logging.log4j.message.SimpleMessage import java.util.* //Returns an iterator that traverses all the exception's cause chain stopping in case of loops (an exception caused by itself) @@ -28,18 +26,6 @@ fun Throwable.walkExceptionCausedByList() : Iterator { } } -fun Message.withErrorCodeFor(error: Throwable?, level: Level): Message { - - return when { - error != null && level.isInRange(Level.FATAL, Level.WARN) -> { - val logMessage = this.formattedMessage - val message = error.walkExceptionCausedByList().asSequence().mapNotNull(Throwable::message).joinToString(" - ") - CompositeMessage("$logMessage - $message [errorCode=${error.errorCode()}, moreInformationAt=${error.errorCodeLocationUrl()}]", format, parameters, throwable) - } - else -> this - } -} - fun Throwable.errorCodeLocationUrl() = "https://errors.corda.net/${CordaVersion.platformEditionCode}/${CordaVersion.semanticVersion}/${errorCode()}" fun Throwable.errorCode(hashedFields: (Throwable) -> Array = Throwable::defaultHashedFields): String { diff --git a/common/logging/src/test/kotlin/net/corda/commmon/logging/ExceptionsErrorCodeFunctionsTest.kt b/common/logging/src/test/kotlin/net/corda/commmon/logging/ExceptionsErrorCodeFunctionsTest.kt deleted file mode 100644 index 971f02c13e..0000000000 --- a/common/logging/src/test/kotlin/net/corda/commmon/logging/ExceptionsErrorCodeFunctionsTest.kt +++ /dev/null @@ -1,40 +0,0 @@ -package net.corda.commmon.logging - -import com.natpryce.hamkrest.assertion.assertThat -import com.natpryce.hamkrest.contains -import net.corda.common.logging.withErrorCodeFor -import org.apache.logging.log4j.Level -import org.apache.logging.log4j.message.SimpleMessage -import org.junit.Test -import kotlin.test.assertEquals - -class ExceptionsErrorCodeFunctionsTest { - private companion object { - private const val EXCEPTION_MESSAGE = "This is exception " - private const val TEST_MESSAGE = "This is a test message" - private fun makeChain(previous: Exception?, ttl: Int): Exception { - val current = TestThrowable(ttl, previous) - return if (ttl == 0) { - current - } else { - makeChain(current, ttl - 1) - } - } - } - - @Test(timeout=5_000) - fun `error code for message prints out message and full stack trace`() { - val originalMessage = SimpleMessage(TEST_MESSAGE) - val exception = makeChain(null, 10) - val message = originalMessage.withErrorCodeFor(exception, Level.ERROR) - assertThat(message.formattedMessage, contains(TEST_MESSAGE.toRegex())) - for (i in (0..10)) { - assertThat(message.formattedMessage, contains("$EXCEPTION_MESSAGE $i".toRegex())) - } - assertEquals(message.format, originalMessage.format) - assertEquals(message.parameters, originalMessage.parameters) - assertEquals(message.throwable, originalMessage.throwable) - } - - private class TestThrowable(index: Int, cause: Exception?) : Exception("$EXCEPTION_MESSAGE $index", cause) -} \ No newline at end of file diff --git a/constants.properties b/constants.properties index 97602c1d30..e353a5b6f2 100644 --- a/constants.properties +++ b/constants.properties @@ -51,7 +51,7 @@ jerseyVersion=3.1.6 servletVersion=4.0.1 assertjVersion=3.12.2 slf4JVersion=2.0.12 -log4JVersion=2.23.0 +log4JVersion=2.24.3 okhttpVersion=4.12.0 nettyVersion=4.1.115.Final fileuploadVersion=2.0.0-M1