mirror of
https://github.com/corda/corda.git
synced 2025-06-21 00:23:09 +00:00
CORDA-2942: Allow exception from CordaService
creation to propagate (#5884)
* CORDA-2942: Allow exception from `CordaService` creation to propagate It will ultimately be thrown from Node's `start()` method terminating the node start-up sequence. * CORDA-2942: Be lenient when retrievign the name of the Notary Some tests setup such that they do nto have Notary running.
This commit is contained in:
committed by
Matthew Nesbit
parent
1380779a9c
commit
42a2ed98e2
@ -80,7 +80,7 @@ class CordaServiceIssueOnceAtStartupTests {
|
||||
// Without the "secret" property service upon instantiation will be subscribed to lifecycle events which would be unwanted.
|
||||
// Also do not do this for Notary
|
||||
val myName = services.myInfo.legalIdentities.single().name
|
||||
val notaryName = services.networkMapCache.notaryIdentities.single().name
|
||||
val notaryName = services.networkMapCache.notaryIdentities.firstOrNull()?.name
|
||||
if(java.lang.Boolean.getBoolean(armedPropName) && myName != notaryName) {
|
||||
services.register(observer = MyServiceLifecycleObserver())
|
||||
} else {
|
||||
|
@ -757,7 +757,6 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
||||
// This sets the Cordapp classloader on the contextClassLoader of the current thread, prior to initializing services
|
||||
// Needed because of bug CORDA-2653 - some Corda services can utilise third-party libraries that require access to
|
||||
// the Thread context class loader
|
||||
|
||||
val oldContextClassLoader: ClassLoader? = Thread.currentThread().contextClassLoader
|
||||
try {
|
||||
Thread.currentThread().contextClassLoader = cordappLoader.appClassLoader
|
||||
@ -768,14 +767,17 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
|
||||
} catch (e: NoSuchMethodException) {
|
||||
log.error("${it.name}, as a Corda service, must have a constructor with a single parameter of type " +
|
||||
ServiceHub::class.java.name)
|
||||
throw e
|
||||
} catch (e: ServiceInstantiationException) {
|
||||
if (e.cause != null) {
|
||||
log.error("Corda service ${it.name} failed to instantiate. Reason was: ${e.cause?.rootMessage}", e.cause)
|
||||
} else {
|
||||
log.error("Corda service ${it.name} failed to instantiate", e)
|
||||
}
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
log.error("Unable to install Corda service ${it.name}", e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
Reference in New Issue
Block a user