Renamed FlowSessionException to UnexpectedFlowEndException

This commit is contained in:
Shams Asari 2017-07-13 17:09:15 +01:00
parent 729eaed362
commit ae01d658b6
5 changed files with 14 additions and 14 deletions

View File

@ -25,6 +25,6 @@ open class FlowException(message: String?, cause: Throwable?) : CordaException(m
* that we were not expecting), or the other side had an internal error, or the other side terminated when we * that we were not expecting), or the other side had an internal error, or the other side terminated when we
* were waiting for a response. * were waiting for a response.
*/ */
class FlowSessionException(message: String?, cause: Throwable?) : CordaRuntimeException(message, cause) { class UnexpectedFlowEndException(message: String?, cause: Throwable?) : CordaRuntimeException(message, cause) {
constructor(msg: String) : this(msg, null) constructor(msg: String) : this(msg, null)
} }

View File

@ -71,7 +71,7 @@ class ContractUpgradeFlowTest {
// The request is expected to be rejected because party B hasn't authorised the upgrade yet. // The request is expected to be rejected because party B hasn't authorised the upgrade yet.
val rejectedFuture = a.services.startFlow(ContractUpgradeFlow(atx!!.tx.outRef(0), DummyContractV2::class.java)).resultFuture val rejectedFuture = a.services.startFlow(ContractUpgradeFlow(atx!!.tx.outRef(0), DummyContractV2::class.java)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertFailsWith(FlowSessionException::class) { rejectedFuture.getOrThrow() } assertFailsWith(UnexpectedFlowEndException::class) { rejectedFuture.getOrThrow() }
// Party B authorise the contract state upgrade. // Party B authorise the contract state upgrade.
b.services.vaultService.authoriseContractUpgrade(btx!!.tx.outRef<ContractState>(0), DummyContractV2::class.java) b.services.vaultService.authoriseContractUpgrade(btx!!.tx.outRef<ContractState>(0), DummyContractV2::class.java)
@ -141,7 +141,7 @@ class ContractUpgradeFlowTest {
DummyContractV2::class.java).returnValue DummyContractV2::class.java).returnValue
mockNet.runNetwork() mockNet.runNetwork()
assertFailsWith(FlowSessionException::class) { rejectedFuture.getOrThrow() } assertFailsWith(UnexpectedFlowEndException::class) { rejectedFuture.getOrThrow() }
// Party B authorise the contract state upgrade. // Party B authorise the contract state upgrade.
rpcB.authoriseContractUpgrade(btx!!.tx.outRef<ContractState>(0), DummyContractV2::class.java) rpcB.authoriseContractUpgrade(btx!!.tx.outRef<ContractState>(0), DummyContractV2::class.java)

View File

@ -255,7 +255,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
state = FlowSessionState.Initiated(peerParty, sessionInitResponse.initiatedSessionId) state = FlowSessionState.Initiated(peerParty, sessionInitResponse.initiatedSessionId)
} else { } else {
sessionInitResponse as SessionReject sessionInitResponse as SessionReject
throw FlowSessionException("Party ${state.sendToParty} rejected session request: ${sessionInitResponse.errorMessage}") throw UnexpectedFlowEndException("Party ${state.sendToParty} rejected session request: ${sessionInitResponse.errorMessage}")
} }
} }
@ -357,7 +357,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
session.erroredEnd(message) session.erroredEnd(message)
} else { } else {
val expectedType = receiveRequest.userReceiveType?.name ?: receiveType.simpleName val expectedType = receiveRequest.userReceiveType?.name ?: receiveType.simpleName
throw FlowSessionException("Counterparty flow on ${session.state.sendToParty} has completed without " + throw UnexpectedFlowEndException("Counterparty flow on ${session.state.sendToParty} has completed without " +
"sending a $expectedType") "sending a $expectedType")
} }
} else { } else {
@ -371,7 +371,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
(end.errorResponse as java.lang.Throwable).fillInStackTrace() (end.errorResponse as java.lang.Throwable).fillInStackTrace()
throw end.errorResponse throw end.errorResponse
} else { } else {
throw FlowSessionException("Counterparty flow on ${state.sendToParty} had an internal error and has terminated") throw UnexpectedFlowEndException("Counterparty flow on ${state.sendToParty} had an internal error and has terminated")
} }
} }

View File

@ -2,7 +2,7 @@ package net.corda.node.services.statemachine
import net.corda.core.flows.FlowException import net.corda.core.flows.FlowException
import net.corda.core.flows.FlowLogic import net.corda.core.flows.FlowLogic
import net.corda.core.flows.FlowSessionException import net.corda.core.flows.UnexpectedFlowEndException
import net.corda.core.identity.Party import net.corda.core.identity.Party
import net.corda.core.serialization.CordaSerializable import net.corda.core.serialization.CordaSerializable
import net.corda.core.utilities.UntrustworthyData import net.corda.core.utilities.UntrustworthyData
@ -45,7 +45,7 @@ fun <T> ReceivedSessionMessage<SessionData>.checkPayloadIs(type: Class<T>): Untr
if (type.isInstance(message.payload)) { if (type.isInstance(message.payload)) {
return UntrustworthyData(type.cast(message.payload)) return UntrustworthyData(type.cast(message.payload))
} else { } else {
throw FlowSessionException("We were expecting a ${type.name} from $sender but we instead got a " + throw UnexpectedFlowEndException("We were expecting a ${type.name} from $sender but we instead got a " +
"${message.payload.javaClass.name} (${message.payload})") "${message.payload.javaClass.name} (${message.payload})")
} }
} }

View File

@ -377,7 +377,7 @@ class FlowFrameworkTests {
node2.registerFlowFactory(ReceiveFlow::class) { NoOpFlow() } node2.registerFlowFactory(ReceiveFlow::class) { NoOpFlow() }
val resultFuture = node1.services.startFlow(ReceiveFlow(node2.info.legalIdentity)).resultFuture val resultFuture = node1.services.startFlow(ReceiveFlow(node2.info.legalIdentity)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy { assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
resultFuture.getOrThrow() resultFuture.getOrThrow()
}.withMessageContaining(String::class.java.name) // Make sure the exception message mentions the type the flow was expecting to receive }.withMessageContaining(String::class.java.name) // Make sure the exception message mentions the type the flow was expecting to receive
} }
@ -400,7 +400,7 @@ class FlowFrameworkTests {
Notification.createOnError(erroringFlowFuture.get().exceptionThrown) Notification.createOnError(erroringFlowFuture.get().exceptionThrown)
) )
val receiveFlowException = assertFailsWith(FlowSessionException::class) { val receiveFlowException = assertFailsWith(UnexpectedFlowEndException::class) {
receiveFlowResult.getOrThrow() receiveFlowResult.getOrThrow()
} }
assertThat(receiveFlowException.message).doesNotContain("evil bug!") assertThat(receiveFlowException.message).doesNotContain("evil bug!")
@ -486,7 +486,7 @@ class FlowFrameworkTests {
node1Fiber.resultFuture.getOrThrow() node1Fiber.resultFuture.getOrThrow()
} }
val node2ResultFuture = node2Fiber.getOrThrow().resultFuture val node2ResultFuture = node2Fiber.getOrThrow().resultFuture
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy { assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
node2ResultFuture.getOrThrow() node2ResultFuture.getOrThrow()
} }
@ -539,7 +539,7 @@ class FlowFrameworkTests {
node2.registerFlowFactory(ReceiveFlow::class) { SendFlow(NonSerialisableData(1), it) } node2.registerFlowFactory(ReceiveFlow::class) { SendFlow(NonSerialisableData(1), it) }
val result = node1.services.startFlow(ReceiveFlow(node2.info.legalIdentity)).resultFuture val result = node1.services.startFlow(ReceiveFlow(node2.info.legalIdentity)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy { assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
result.getOrThrow() result.getOrThrow()
} }
} }
@ -581,7 +581,7 @@ class FlowFrameworkTests {
} }
val waiter = node2.services.startFlow(WaitingFlows.Waiter(stx, node1.info.legalIdentity)).resultFuture val waiter = node2.services.startFlow(WaitingFlows.Waiter(stx, node1.info.legalIdentity)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy { assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
waiter.getOrThrow() waiter.getOrThrow()
} }
} }
@ -643,7 +643,7 @@ class FlowFrameworkTests {
track = false) track = false)
val result = node1.services.startFlow(UpgradedFlow(node2.info.legalIdentity)).resultFuture val result = node1.services.startFlow(UpgradedFlow(node2.info.legalIdentity)).resultFuture
mockNet.runNetwork() mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy { assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
result.getOrThrow() result.getOrThrow()
}.withMessageContaining("Version") }.withMessageContaining("Version")
} }