[CORDA-3628] - Avoid sending actions to the state machine if no messages are to be sent (#6074)

This commit is contained in:
Dimos Raptis 2020-03-17 16:51:07 +00:00 committed by GitHub
parent 80cf34b81a
commit eba113621c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -46,7 +46,11 @@ sealed class Action {
data class SendMultiple(
val sendInitial: List<SendInitial>,
val sendExisting: List<SendExisting>
): 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].

View File

@ -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))
}