mirror of
https://github.com/corda/corda.git
synced 2025-06-19 07:38:22 +00:00
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,
|
coerce: (D) -> DI,
|
||||||
dsl: DI.() -> A
|
dsl: DI.() -> A
|
||||||
): A {
|
): A {
|
||||||
val serializationEnv = setDriverSerialization(driverDsl.cordappsClassLoader)
|
setDriverSerialization(driverDsl.cordappsClassLoader).use { _ ->
|
||||||
val shutdownHook = addShutdownHook(driverDsl::shutdown)
|
val shutdownHook = addShutdownHook(driverDsl::shutdown)
|
||||||
try {
|
try {
|
||||||
driverDsl.start()
|
driverDsl.start()
|
||||||
@ -1140,7 +1140,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
|||||||
} finally {
|
} finally {
|
||||||
driverDsl.shutdown()
|
driverDsl.shutdown()
|
||||||
shutdownHook.cancel()
|
shutdownHook.cancel()
|
||||||
serializationEnv?.close()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1157,7 +1157,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
|||||||
driverDslWrapper: (DriverDSLImpl) -> D,
|
driverDslWrapper: (DriverDSLImpl) -> D,
|
||||||
coerce: (D) -> DI, dsl: DI.() -> A
|
coerce: (D) -> DI, dsl: DI.() -> A
|
||||||
): A {
|
): A {
|
||||||
val serializationEnv = setDriverSerialization()
|
setDriverSerialization().use { _ ->
|
||||||
val driverDsl = driverDslWrapper(
|
val driverDsl = driverDslWrapper(
|
||||||
DriverDSLImpl(
|
DriverDSLImpl(
|
||||||
portAllocation = defaultParameters.portAllocation,
|
portAllocation = defaultParameters.portAllocation,
|
||||||
@ -1191,7 +1191,7 @@ fun <DI : DriverDSL, D : InternalDriverDSL, A> genericDriver(
|
|||||||
} finally {
|
} finally {
|
||||||
driverDsl.shutdown()
|
driverDsl.shutdown()
|
||||||
shutdownHook.cancel()
|
shutdownHook.cancel()
|
||||||
serializationEnv?.close()
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user