mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
[CORDA-1356]: CashException is unable to derisalize with AMQP through RPC. (fix). (#3274)
This commit is contained in:
parent
ef2772e328
commit
e44b6c6f4a
@ -7,6 +7,8 @@ release, see :doc:`upgrade-notes`.
|
||||
Unreleased
|
||||
==========
|
||||
|
||||
* Fixed an issue with ``CashException`` not being able to deserialise after the introduction of AMQP for RPC.
|
||||
|
||||
* Removed -xmx VM argument from Explorer's Capsule setup. This helps avoiding out of memory errors.
|
||||
|
||||
* Shell now kills an ongoing flow when CTRL+C is pressed in the terminal.
|
||||
|
@ -0,0 +1,35 @@
|
||||
package net.corda.finance.compat
|
||||
|
||||
import net.corda.core.flows.FlowLogic
|
||||
import net.corda.core.flows.StartableByRPC
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.finance.flows.CashException
|
||||
import net.corda.node.services.Permissions.Companion.all
|
||||
import net.corda.testing.driver.DriverParameters
|
||||
import net.corda.testing.driver.driver
|
||||
import net.corda.testing.node.User
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.Test
|
||||
|
||||
class CashExceptionSerialisationTest {
|
||||
@Test
|
||||
fun `cash exception with a cause can be serialised with AMQP`() {
|
||||
driver(DriverParameters(startNodesInProcess = true)) {
|
||||
val node = startNode(rpcUsers = listOf(User("mark", "dadada", setOf(all())))).getOrThrow()
|
||||
val action = { node.rpc.startFlow(::CashExceptionThrowingFlow).returnValue.getOrThrow() }
|
||||
assertThatThrownBy(action).isInstanceOfSatisfying(CashException::class.java) { thrown ->
|
||||
assertThat(thrown).hasNoCause()
|
||||
assertThat(thrown.stackTrace).isEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@StartableByRPC
|
||||
class CashExceptionThrowingFlow : FlowLogic<Unit>() {
|
||||
override fun call() {
|
||||
throw CashException("BOOM!", IllegalStateException("Nope dude!"))
|
||||
}
|
||||
}
|
@ -50,4 +50,7 @@ abstract class AbstractCashFlow<out T>(override val progressTracker: ProgressTra
|
||||
abstract class AbstractRequest(val amount: Amount<Currency>)
|
||||
}
|
||||
|
||||
class CashException(message: String, cause: Throwable) : FlowException(message, cause)
|
||||
// The internal constructor here allows the ThrowableSerializer to find a suitable constructor even if the `cause` field is removed using reflection by the RPC proxies.
|
||||
class CashException internal constructor(cause: Throwable?, message: String) : FlowException(message, cause) {
|
||||
constructor(message: String, cause: Throwable) : this(cause, message)
|
||||
}
|
Loading…
Reference in New Issue
Block a user