CORDA-3335 Corda Shell flow kill - better warning for misformatted flow ID (#5601)

* CORDA-3081 warn that flow ID passed to flow kill is malformed as due to JDK8 doesn't fully validate it (JDK8 bug https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8159339)

* CORDA-3335 Corda Shell flow kill - better warning for misformatted flow ID - exit earlier and don't RPC to node, refactoring for detekt
This commit is contained in:
szymonsztuka 2019-10-22 11:32:17 +01:00 committed by Anthony Keenan
parent 5da114caa3
commit b524c6368b

View File

@ -97,6 +97,7 @@ object InteractiveShell {
private var classLoader: ClassLoader? = null
private lateinit var shellConfiguration: ShellConfiguration
private var onExit: () -> Unit = {}
private const val uuidStringSize = 36
@JvmStatic
fun getCordappsClassloader() = classLoader
@ -425,7 +426,14 @@ object InteractiveShell {
log.error("Failed to parse flow ID", e)
return
}
//auxiliary validation - workaround for JDK8 bug https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8159339
if (id.length < uuidStringSize) {
val msg = "Can not kill the flow. Flow ID of '$id' seems to be malformed - a UUID should have $uuidStringSize characters. " +
"Expand the terminal window to see the full UUID value."
output.println(msg, Color.red)
log.warn(msg)
return
}
if (rpcOps.killFlow(runId)) {
output.println("Killed flow $runId", Color.yellow)
} else {