Merge pull request #1046 from corda/shams-flow-session-exception-rename

Renamed FlowSessionException to UnexpectedFlowEndException
This commit is contained in:
Shams Asari 2017-07-14 17:10:08 +01:00 committed by GitHub
commit 6ba3ae870c
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
* 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)
}

View File

@ -71,7 +71,7 @@ class ContractUpgradeFlowTest {
// 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
mockNet.runNetwork()
assertFailsWith(FlowSessionException::class) { rejectedFuture.getOrThrow() }
assertFailsWith(UnexpectedFlowEndException::class) { rejectedFuture.getOrThrow() }
// Party B authorise the contract state upgrade.
b.services.vaultService.authoriseContractUpgrade(btx!!.tx.outRef<ContractState>(0), DummyContractV2::class.java)
@ -141,7 +141,7 @@ class ContractUpgradeFlowTest {
DummyContractV2::class.java).returnValue
mockNet.runNetwork()
assertFailsWith(FlowSessionException::class) { rejectedFuture.getOrThrow() }
assertFailsWith(UnexpectedFlowEndException::class) { rejectedFuture.getOrThrow() }
// Party B authorise the contract state upgrade.
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)
} else {
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)
} else {
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")
}
} else {
@ -371,7 +371,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
(end.errorResponse as java.lang.Throwable).fillInStackTrace()
throw end.errorResponse
} 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.FlowLogic
import net.corda.core.flows.FlowSessionException
import net.corda.core.flows.UnexpectedFlowEndException
import net.corda.core.identity.Party
import net.corda.core.serialization.CordaSerializable
import net.corda.core.utilities.UntrustworthyData
@ -45,7 +45,7 @@ fun <T> ReceivedSessionMessage<SessionData>.checkPayloadIs(type: Class<T>): Untr
if (type.isInstance(message.payload)) {
return UntrustworthyData(type.cast(message.payload))
} 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})")
}
}

View File

@ -377,7 +377,7 @@ class FlowFrameworkTests {
node2.registerFlowFactory(ReceiveFlow::class) { NoOpFlow() }
val resultFuture = node1.services.startFlow(ReceiveFlow(node2.info.legalIdentity)).resultFuture
mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy {
assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
resultFuture.getOrThrow()
}.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)
)
val receiveFlowException = assertFailsWith(FlowSessionException::class) {
val receiveFlowException = assertFailsWith(UnexpectedFlowEndException::class) {
receiveFlowResult.getOrThrow()
}
assertThat(receiveFlowException.message).doesNotContain("evil bug!")
@ -486,7 +486,7 @@ class FlowFrameworkTests {
node1Fiber.resultFuture.getOrThrow()
}
val node2ResultFuture = node2Fiber.getOrThrow().resultFuture
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy {
assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
node2ResultFuture.getOrThrow()
}
@ -539,7 +539,7 @@ class FlowFrameworkTests {
node2.registerFlowFactory(ReceiveFlow::class) { SendFlow(NonSerialisableData(1), it) }
val result = node1.services.startFlow(ReceiveFlow(node2.info.legalIdentity)).resultFuture
mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy {
assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
result.getOrThrow()
}
}
@ -581,7 +581,7 @@ class FlowFrameworkTests {
}
val waiter = node2.services.startFlow(WaitingFlows.Waiter(stx, node1.info.legalIdentity)).resultFuture
mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy {
assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
waiter.getOrThrow()
}
}
@ -643,7 +643,7 @@ class FlowFrameworkTests {
track = false)
val result = node1.services.startFlow(UpgradedFlow(node2.info.legalIdentity)).resultFuture
mockNet.runNetwork()
assertThatExceptionOfType(FlowSessionException::class.java).isThrownBy {
assertThatExceptionOfType(UnexpectedFlowEndException::class.java).isThrownBy {
result.getOrThrow()
}.withMessageContaining("Version")
}