mirror of
https://github.com/corda/corda.git
synced 2025-06-23 17:53:31 +00:00
[CORDA-1879]: Ensure Node dies on unrecoverable errors. (#4213)
This commit is contained in:
committed by
GitHub
parent
ac23fcdf24
commit
dc62b20c5d
@ -4,6 +4,7 @@ import net.corda.core.KeepForDJVM
|
||||
import net.corda.core.internal.extractFile
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import java.io.FileNotFoundException
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import java.security.PublicKey
|
||||
@ -36,10 +37,10 @@ interface Attachment : NamedByHash {
|
||||
@JvmDefault
|
||||
fun openAsJAR(): JarInputStream {
|
||||
val stream = open()
|
||||
try {
|
||||
return JarInputStream(stream)
|
||||
} catch (t: Throwable) {
|
||||
stream.use { throw t }
|
||||
return try {
|
||||
JarInputStream(stream)
|
||||
} catch (e: IOException) {
|
||||
stream.use { throw e }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ fun <V, W> CordaFuture<out V>.flatMap(transform: (V) -> CordaFuture<out W>): Cor
|
||||
thenMatch(success@ {
|
||||
result.captureLater(try {
|
||||
transform(it)
|
||||
} catch (t: Throwable) {
|
||||
result.setException(t)
|
||||
} catch (e: Exception) {
|
||||
result.setException(e)
|
||||
return@success
|
||||
})
|
||||
}, {
|
||||
@ -128,8 +128,8 @@ interface ValueOrException<in V> {
|
||||
fun capture(block: () -> V): Boolean {
|
||||
return set(try {
|
||||
block()
|
||||
} catch (t: Throwable) {
|
||||
return setException(t)
|
||||
} catch (e: Exception) {
|
||||
return setException(e)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -153,8 +153,8 @@ internal class CordaFutureImpl<V>(private val impl: CompletableFuture<V> = Compl
|
||||
impl.whenComplete { _, _ ->
|
||||
try {
|
||||
callback(this)
|
||||
} catch (t: Throwable) {
|
||||
log.error(listenerFailedMessage, t)
|
||||
} catch (e: Exception) {
|
||||
log.error(listenerFailedMessage, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ data class LedgerTransaction @JvmOverloads constructor(
|
||||
is Try.Success -> {
|
||||
try {
|
||||
contractInstances.add(result.value.newInstance())
|
||||
} catch (e: Throwable) {
|
||||
} catch (e: Exception) {
|
||||
throw TransactionVerificationException.ContractCreationError(id, result.value.name, e)
|
||||
}
|
||||
}
|
||||
@ -202,7 +202,7 @@ data class LedgerTransaction @JvmOverloads constructor(
|
||||
contractInstances.forEach { contract ->
|
||||
try {
|
||||
contract.verify(this)
|
||||
} catch (e: Throwable) {
|
||||
} catch (e: Exception) {
|
||||
throw TransactionVerificationException.ContractRejection(id, contract, e)
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ sealed class Try<out A> {
|
||||
inline fun <T> on(body: () -> T): Try<T> {
|
||||
return try {
|
||||
Success(body())
|
||||
} catch (t: Throwable) {
|
||||
Failure(t)
|
||||
} catch (e: Exception) {
|
||||
Failure(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user