CORDA-2744 - Prevent ClassCastException if error during initial registration (#5712)

* Prevent class cast exception if error during initial registration

* Appeasing detekt
This commit is contained in:
Oliver Knowles 2019-11-14 16:13:08 +00:00 committed by Anthony Keenan
parent 7d5c59e9cc
commit 4a8c73bf4a

View File

@ -84,10 +84,14 @@ class InitialRegistration(val baseDirectory: Path, private val networkRootTrustS
}
private fun initialRegistration(config: NodeConfiguration) {
// Null checks for [compatibilityZoneURL], [rootTruststorePath] and [rootTruststorePassword] has been done in [CmdLineOptions.loadConfig]
attempt { registerWithNetwork(config) }.doOnFailure(Consumer(this::handleRegistrationError)) as Try.Success
// At this point the node registration was successful. We can delete the marker file.
deleteNodeRegistrationMarker(baseDirectory)
// Null checks for [compatibilityZoneURL], [rootTruststorePath] and
// [rootTruststorePassword] have been done in [CmdLineOptions.loadConfig]
val result = attempt { registerWithNetwork(config) }.doOnFailure(Consumer(this::handleRegistrationError))
if (result.isSuccess) {
// At this point the node registration was successful. We can delete the marker file.
deleteNodeRegistrationMarker(baseDirectory)
}
}
private fun deleteNodeRegistrationMarker(baseDir: Path) {