From eba113621c68c5914fb34b3dc23b0e896711b2a7 Mon Sep 17 00:00:00 2001 From: Dimos Raptis Date: Tue, 17 Mar 2020 16:51:07 +0000 Subject: [PATCH] [CORDA-3628] - Avoid sending actions to the state machine if no messages are to be sent (#6074) --- .../kotlin/net/corda/node/services/statemachine/Action.kt | 6 +++++- .../statemachine/transitions/StartedFlowTransition.kt | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/Action.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/Action.kt index 14f8229fec..0c4bbe4b3a 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/Action.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/Action.kt @@ -46,7 +46,11 @@ sealed class Action { data class SendMultiple( val sendInitial: List, val sendExisting: List - ): Action() + ): Action() { + init { + check(sendInitial.isNotEmpty() || sendExisting.isNotEmpty()) { "At least one of the lists with initial or existing session messages should contain items." } + } + } /** * Persist the specified [checkpoint]. diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt index 6f9956b692..4a10c335bd 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt @@ -289,7 +289,9 @@ class StartedFlowTransition( } } ?: emptyList() - actions.add(Action.SendMultiple(sendInitialActions, sendExistingActions)) + if (sendInitialActions.isNotEmpty() || sendExistingActions.isNotEmpty()) { + actions.add(Action.SendMultiple(sendInitialActions, sendExistingActions)) + } currentState = currentState.copy(checkpoint = checkpoint.copy(sessions = newSessions)) }