mirror of
https://github.com/corda/corda.git
synced 2025-06-19 07:38:22 +00:00
Merge pull request #5988 from corda/chrisr3-driver-shutdown
NOTICK: Tidy up driver shutdown so that resources are always released on error.
This commit is contained in:
@ -1129,7 +1129,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
||||
coerce: (D) -> DI,
|
||||
dsl: DI.() -> A
|
||||
): A {
|
||||
val serializationEnv = setDriverSerialization(driverDsl.cordappsClassLoader)
|
||||
setDriverSerialization(driverDsl.cordappsClassLoader).use { _ ->
|
||||
val shutdownHook = addShutdownHook(driverDsl::shutdown)
|
||||
try {
|
||||
driverDsl.start()
|
||||
@ -1140,7 +1140,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
||||
} finally {
|
||||
driverDsl.shutdown()
|
||||
shutdownHook.cancel()
|
||||
serializationEnv?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1157,7 +1157,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
||||
driverDslWrapper: (DriverDSLImpl) -> D,
|
||||
coerce: (D) -> DI, dsl: DI.() -> A
|
||||
): A {
|
||||
val serializationEnv = setDriverSerialization()
|
||||
setDriverSerialization().use { _ ->
|
||||
val driverDsl = driverDslWrapper(
|
||||
DriverDSLImpl(
|
||||
portAllocation = defaultParameters.portAllocation,
|
||||
@ -1191,7 +1191,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
||||
} finally {
|
||||
driverDsl.shutdown()
|
||||
shutdownHook.cancel()
|
||||
serializationEnv?.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user