From f59b878dc6028a4c8c0e01a150aad73a4e848304 Mon Sep 17 00:00:00 2001 From: a10zn8 Date: Wed, 14 Dec 2022 15:06:03 +0400 Subject: [PATCH] do not call fillInStackTrace in exception constructor in happy path --- .../io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt | 3 ++- .../dshackle/upstream/rpcclient/JsonRpcException.kt | 5 +++-- .../groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt index c30f3f89..87d3138f 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/ethereum/WsConnection.kt @@ -401,7 +401,8 @@ open class WsConnection( JsonRpcError( RpcResponseError.CODE_INTERNAL_ERROR, "Response not received from WebSocket" - ) + ), + false ) val response = Flux.from(rpcReceive.asFlux()) diff --git a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt index 5dbaa65e..b1a1b1d4 100644 --- a/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt +++ b/src/main/kotlin/io/emeraldpay/dshackle/upstream/rpcclient/JsonRpcException.kt @@ -19,8 +19,9 @@ import io.emeraldpay.etherjar.rpc.RpcException class JsonRpcException( val id: JsonRpcResponse.Id, - val error: JsonRpcError -) : Exception(error.message) { + val error: JsonRpcError, + writableStackTrace: Boolean = true +) : Exception(error.message, null, true, writableStackTrace) { constructor(id: Int, message: String) : this(JsonRpcResponse.NumberId(id), JsonRpcError(-32005, message)) diff --git a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy index 164ee633..72fb42be 100644 --- a/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy +++ b/src/test/groovy/io/emeraldpay/dshackle/rpc/NativeCallSpec.groovy @@ -168,7 +168,7 @@ class NativeCallSpec extends Specification { nativeCall.quorumReaderFactory = Mock(QuorumReaderFactory) { 1 * create(_, _, _) >> Mock(Reader) { 1 * read(new JsonRpcRequest("eth_test", [], 10)) >> Mono.error( - new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz")) + new JsonRpcException(JsonRpcResponse.Id.from(12), new JsonRpcError(-32123, "Foo Bar", "Foo Bar Baz"), true) ) } }