ENT-11263: Remove TooGenericExceptionCaught detekt rule

This commit is contained in:
Shams Asari 2023-12-07 13:30:26 +00:00
parent 11d0054fcc
commit e2bcd0499e
43 changed files with 59 additions and 294 deletions

View File

@ -150,7 +150,6 @@ internal class RPCClientProxyHandler(
} }
} }
@Suppress("TooGenericExceptionCaught")
private fun closeObservable(observable: UnicastSubject<Notification<*>>) { private fun closeObservable(observable: UnicastSubject<Notification<*>>) {
// Notify listeners of the observables that the connection is being terminated. // Notify listeners of the observables that the connection is being terminated.
try { try {
@ -589,7 +588,6 @@ internal class RPCClientProxyHandler(
} }
if (observableIds != null) { if (observableIds != null) {
log.debug { "Reaping ${observableIds.size} observables" } log.debug { "Reaping ${observableIds.size} observables" }
@Suppress("TooGenericExceptionCaught")
try { try {
sendMessage(RPCApi.ClientToServer.ObservablesClosed(observableIds)) sendMessage(RPCApi.ClientToServer.ObservablesClosed(observableIds))
} catch(ex: Exception) { } catch(ex: Exception) {

View File

@ -253,7 +253,6 @@ class FlowExternalAsyncOperationTest : AbstractFlowExternalOperationTest() {
@StartableByRPC @StartableByRPC
class FlowWithExternalAsyncOperationThatDirectlyAccessesServiceHubFailsRetry(party: Party) : FlowWithExternalProcess(party) { class FlowWithExternalAsyncOperationThatDirectlyAccessesServiceHubFailsRetry(party: Party) : FlowWithExternalProcess(party) {
@Suppress("TooGenericExceptionCaught")
@Suspendable @Suspendable
override fun testCode(): Any { override fun testCode(): Any {
return await(ExternalAsyncOperation(serviceHub) { _, _ -> return await(ExternalAsyncOperation(serviceHub) { _, _ ->

View File

@ -293,7 +293,6 @@ class FlowExternalOperationTest : AbstractFlowExternalOperationTest() {
@StartableByRPC @StartableByRPC
class FlowWithExternalOperationThatDirectlyAccessesServiceHubFailsRetry(party: Party) : FlowWithExternalProcess(party) { class FlowWithExternalOperationThatDirectlyAccessesServiceHubFailsRetry(party: Party) : FlowWithExternalProcess(party) {
@Suppress("TooGenericExceptionCaught")
@Suspendable @Suspendable
override fun testCode(): Any { override fun testCode(): Any {
try { try {

View File

@ -14,6 +14,7 @@ import java.io.InputStream
import java.security.Provider import java.security.Provider
import java.security.SecureRandom import java.security.SecureRandom
import java.security.SecureRandomSpi import java.security.SecureRandomSpi
import kotlin.system.exitProcess
/** /**
* This has been migrated into a separate class so that it * This has been migrated into a separate class so that it
@ -29,23 +30,22 @@ val platformSecureRandom: () -> SecureRandom = when {
} }
class PlatformSecureRandomService(provider: Provider) class PlatformSecureRandomService(provider: Provider)
: Provider.Service(provider, "SecureRandom", algorithm, PlatformSecureRandomSpi::javaClass.name, null, null) { : Provider.Service(provider, "SecureRandom", ALGORITHM, PlatformSecureRandomSpi::javaClass.name, null, null) {
companion object { companion object {
const val algorithm = "CordaPRNG" const val ALGORITHM = "CordaPRNG"
private val logger = loggerFor<PlatformSecureRandomService>() private val logger = loggerFor<PlatformSecureRandomService>()
} }
private val instance: SecureRandomSpi = if (SystemUtils.IS_OS_LINUX) tryAndUseLinuxSecureRandomSpi() else PlatformSecureRandomSpi() private val instance: SecureRandomSpi = if (SystemUtils.IS_OS_LINUX) tryAndUseLinuxSecureRandomSpi() else PlatformSecureRandomSpi()
@Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown")
private fun tryAndUseLinuxSecureRandomSpi(): SecureRandomSpi = try { private fun tryAndUseLinuxSecureRandomSpi(): SecureRandomSpi = try {
LinuxSecureRandomSpi() LinuxSecureRandomSpi()
} catch (e: Exception) { } catch (e: Exception) {
logger.error("Unable to initialise LinuxSecureRandomSpi. The exception logged with this message might assist with diagnosis." + logger.error("Unable to initialise LinuxSecureRandomSpi. The exception logged with this message might assist with diagnosis." +
" The process will now exit.", e) " The process will now exit.", e)
System.exit(1) exitProcess(1)
throw RuntimeException("Never reached, but calms the compiler.")
} }
override fun newInstance(constructorParameter: Any?) = instance override fun newInstance(constructorParameter: Any?) = instance
@ -63,7 +63,7 @@ private class PlatformSecureRandomSpi : SecureRandomSpi() {
override fun engineGenerateSeed(numBytes: Int): ByteArray = secureRandom.generateSeed(numBytes) override fun engineGenerateSeed(numBytes: Int): ByteArray = secureRandom.generateSeed(numBytes)
} }
@Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown") @Suppress("TooGenericExceptionThrown")
private class LinuxSecureRandomSpi : SecureRandomSpi() { private class LinuxSecureRandomSpi : SecureRandomSpi() {
private fun openURandom(): InputStream { private fun openURandom(): InputStream {
try { try {
@ -91,5 +91,5 @@ private class LinuxSecureRandomSpi : SecureRandomSpi() {
// This is safe to share because of the underlying implementation of SecureRandomSpi // This is safe to share because of the underlying implementation of SecureRandomSpi
private val sharedSecureRandom: SecureRandom by lazy(LazyThreadSafetyMode.PUBLICATION) { private val sharedSecureRandom: SecureRandom by lazy(LazyThreadSafetyMode.PUBLICATION) {
SecureRandom.getInstance(PlatformSecureRandomService.algorithm) SecureRandom.getInstance(PlatformSecureRandomService.ALGORITHM)
} }

View File

@ -84,7 +84,6 @@ fun <ELEMENT> CordaFuture<out ELEMENT>.mapError(transform: (Throwable) -> Throwa
* But if this future or the transform fails, the returned future's outcome is the same throwable. * But if this future or the transform fails, the returned future's outcome is the same throwable.
* In the case where this future fails, the transform is not invoked. * In the case where this future fails, the transform is not invoked.
*/ */
@Suppress("TooGenericExceptionCaught")
fun <V, W> CordaFuture<out V>.flatMap(transform: (V) -> CordaFuture<out W>): CordaFuture<W> = CordaFutureImpl<W>().also { result -> fun <V, W> CordaFuture<out V>.flatMap(transform: (V) -> CordaFuture<out W>): CordaFuture<W> = CordaFutureImpl<W>().also { result ->
thenMatch(success@ { thenMatch(success@ {
result.captureLater(try { result.captureLater(try {
@ -146,7 +145,6 @@ interface ValueOrException<in V> {
fun captureLater(f: CordaFuture<out V>) = f.then { capture { f.getOrThrow() } } fun captureLater(f: CordaFuture<out V>) = f.then { capture { f.getOrThrow() } }
/** Run the given block (in the foreground) and set this future to its outcome. */ /** Run the given block (in the foreground) and set this future to its outcome. */
@Suppress("TooGenericExceptionCaught")
fun capture(block: () -> V): Boolean { fun capture(block: () -> V): Boolean {
return set(try { return set(try {
block() block()
@ -174,7 +172,6 @@ class CordaFutureImpl<V>(private val impl: CompletableFuture<V> = CompletableFut
override fun setException(t: Throwable) = impl.completeExceptionally(t) override fun setException(t: Throwable) = impl.completeExceptionally(t)
override fun <W> then(callback: (CordaFuture<V>) -> W) = thenImpl(defaultLog, callback) override fun <W> then(callback: (CordaFuture<V>) -> W) = thenImpl(defaultLog, callback)
/** For testing only. */ /** For testing only. */
@Suppress("TooGenericExceptionCaught")
fun <W> thenImpl(log: Logger, callback: (CordaFuture<V>) -> W) { fun <W> thenImpl(log: Logger, callback: (CordaFuture<V>) -> W) {
impl.whenComplete { _, _ -> impl.whenComplete { _, _ ->
try { try {

View File

@ -178,7 +178,6 @@ class TelemetryServiceImpl : SingletonSerializeAsToken(), TelemetryService {
} }
} }
@Suppress("TooGenericExceptionCaught")
inline fun <R> span(name: String, attributes: Map<String, String> = emptyMap(), flowLogic: FlowLogic<*>? = null, block: () -> R): R { inline fun <R> span(name: String, attributes: Map<String, String> = emptyMap(), flowLogic: FlowLogic<*>? = null, block: () -> R): R {
val telemetryId = startSpan(name, attributes, flowLogic) val telemetryId = startSpan(name, attributes, flowLogic)
try { try {
@ -195,7 +194,7 @@ class TelemetryServiceImpl : SingletonSerializeAsToken(), TelemetryService {
} }
@CordaInternal @CordaInternal
@Suppress("LongParameterList", "TooGenericExceptionCaught") @Suppress("LongParameterList")
inline fun <R> spanForFlow(name: String, attributes: Map<String, String>, flowLogic: FlowLogic<*>? = null, remoteSerializedTelemetry: SerializedTelemetry? = null, block: () -> R): R { inline fun <R> spanForFlow(name: String, attributes: Map<String, String>, flowLogic: FlowLogic<*>? = null, remoteSerializedTelemetry: SerializedTelemetry? = null, block: () -> R): R {
val telemetryId = startSpanForFlow(name, attributes, flowLogic, remoteSerializedTelemetry) val telemetryId = startSpanForFlow(name, attributes, flowLogic, remoteSerializedTelemetry)
try { try {

View File

@ -440,7 +440,6 @@ private class Validator(private val ltx: LedgerTransaction, private val transact
* Verify the given [LedgerTransaction]. This includes validating * Verify the given [LedgerTransaction]. This includes validating
* its contents, as well as executing all of its smart contracts. * its contents, as well as executing all of its smart contracts.
*/ */
@Suppress("TooGenericExceptionCaught")
class TransactionVerifier(private val transactionClassLoader: ClassLoader) : Function<Supplier<LedgerTransaction>, Unit> { class TransactionVerifier(private val transactionClassLoader: ClassLoader) : Function<Supplier<LedgerTransaction>, Unit> {
// Loads the contract class from the transactionClassLoader. // Loads the contract class from the transactionClassLoader.
private fun createContractClass(id: SecureHash, contractClassName: ContractClassName): Class<out Contract> { private fun createContractClass(id: SecureHash, contractClassName: ContractClassName): Class<out Contract> {

View File

@ -33,7 +33,6 @@ class ResilientSubscriber<T>(actual: Subscriber<in T>) : SafeSubscriber<T>(actua
* It only delegates to [SafeSubscriber.onError] if it wraps an [ActionSubscriber] which is * It only delegates to [SafeSubscriber.onError] if it wraps an [ActionSubscriber] which is
* a leaf in an Subscribers' tree structure. * a leaf in an Subscribers' tree structure.
*/ */
@Suppress("TooGenericExceptionCaught")
override fun onNext(t: T) { override fun onNext(t: T) {
try { try {
actual.onNext(t) actual.onNext(t)
@ -62,7 +61,6 @@ class ResilientSubscriber<T>(actual: Subscriber<in T>) : SafeSubscriber<T>(actua
/** /**
* Duplicate of [SafeSubscriber._onError]. However, it will not call [Subscriber.unsubscribe]. * Duplicate of [SafeSubscriber._onError]. However, it will not call [Subscriber.unsubscribe].
*/ */
@Suppress("TooGenericExceptionCaught")
override fun _onError(e: Throwable) { override fun _onError(e: Throwable) {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
RxJavaPlugins.getInstance().errorHandler.handleError(e) RxJavaPlugins.getInstance().errorHandler.handleError(e)

View File

@ -8,8 +8,8 @@ import net.corda.core.contracts.TransactionVerificationException
import net.corda.core.contracts.TransactionVerificationException.OverlappingAttachmentsException import net.corda.core.contracts.TransactionVerificationException.OverlappingAttachmentsException
import net.corda.core.contracts.TransactionVerificationException.PackageOwnershipException import net.corda.core.contracts.TransactionVerificationException.PackageOwnershipException
import net.corda.core.crypto.SecureHash import net.corda.core.crypto.SecureHash
import net.corda.core.internal.JAVA_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JAVA_17_CLASS_FILE_FORMAT_MAJOR_VERSION import net.corda.core.internal.JAVA_17_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JAVA_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION
import net.corda.core.internal.JarSignatureCollector import net.corda.core.internal.JarSignatureCollector
import net.corda.core.internal.NamedCacheFactory import net.corda.core.internal.NamedCacheFactory
import net.corda.core.internal.PlatformVersionSwitches import net.corda.core.internal.PlatformVersionSwitches
@ -118,16 +118,11 @@ class AttachmentsClassLoader(attachments: List<Attachment>,
// Reset the value to prevent Error due to a factory already defined // Reset the value to prevent Error due to a factory already defined
factoryField.set(null, null) factoryField.set(null, null)
// Set our custom factory and wrap the current one into it // Set our custom factory and wrap the current one into it
URL.setURLStreamHandlerFactory( URL.setURLStreamHandlerFactory { protocol ->
// Set the factory to a decorator // route between our own and the pre-existing factory
object : URLStreamHandlerFactory { AttachmentURLStreamHandlerFactory.createURLStreamHandler(protocol)
// route between our own and the pre-existing factory ?: existingFactory.createURLStreamHandler(protocol)
override fun createURLStreamHandler(protocol: String): URLStreamHandler? { }
return AttachmentURLStreamHandlerFactory.createURLStreamHandler(protocol)
?: existingFactory.createURLStreamHandler(protocol)
}
}
)
} }
} }
} }
@ -158,9 +153,7 @@ class AttachmentsClassLoader(attachments: List<Attachment>,
checkAttachments(attachments) checkAttachments(attachments)
} }
private class AttachmentHashContext( private class AttachmentHashContext(val buffer: ByteArray = ByteArray(DEFAULT_BUFFER_SIZE))
val txId: SecureHash,
val buffer: ByteArray = ByteArray(DEFAULT_BUFFER_SIZE))
private fun hash(inputStream : InputStream, ctx : AttachmentHashContext) : SecureHash.SHA256 { private fun hash(inputStream : InputStream, ctx : AttachmentHashContext) : SecureHash.SHA256 {
val md = MessageDigest.getInstance(SecureHash.SHA2_256) val md = MessageDigest.getInstance(SecureHash.SHA2_256)
@ -189,7 +182,7 @@ class AttachmentsClassLoader(attachments: List<Attachment>,
// This function attempts to strike a balance between security and usability when it comes to the no-overlap rule. // This function attempts to strike a balance between security and usability when it comes to the no-overlap rule.
// TODO - investigate potential exploits. // TODO - investigate potential exploits.
private fun shouldCheckForNoOverlap(path: String, targetPlatformVersion: Int): Boolean { private fun shouldCheckForNoOverlap(path: String, targetPlatformVersion: Int): Boolean {
require(path.toLowerCase() == path) require(path.lowercase() == path)
require(!path.contains('\\')) require(!path.contains('\\'))
return when { return when {
@ -234,7 +227,7 @@ class AttachmentsClassLoader(attachments: List<Attachment>,
// claim their parts of the Java package namespace via registration with the zone operator. // claim their parts of the Java package namespace via registration with the zone operator.
val classLoaderEntries = mutableMapOf<String, SecureHash>() val classLoaderEntries = mutableMapOf<String, SecureHash>()
val ctx = AttachmentHashContext(sampleTxId) val ctx = AttachmentHashContext()
for (attachment in attachments) { for (attachment in attachments) {
// We may have been given an attachment loaded from the database in which case, important info like // We may have been given an attachment loaded from the database in which case, important info like
// signers is already calculated. // signers is already calculated.
@ -270,7 +263,7 @@ class AttachmentsClassLoader(attachments: List<Attachment>,
// filesystem tries to be case insensitive. This may break developers who attempt to use ProGuard. // filesystem tries to be case insensitive. This may break developers who attempt to use ProGuard.
// //
// Also convert to Unix path separators as all resource/class lookups will expect this. // Also convert to Unix path separators as all resource/class lookups will expect this.
val path = entry.name.toLowerCase(Locale.US).replace('\\', '/') val path = entry.name.lowercase(Locale.US).replace('\\', '/')
// Namespace ownership. We only check class files: resources are loaded relative to a JAR anyway. // Namespace ownership. We only check class files: resources are loaded relative to a JAR anyway.
if (path.endsWith(".class")) { if (path.endsWith(".class")) {
@ -285,7 +278,7 @@ class AttachmentsClassLoader(attachments: List<Attachment>,
for ((namespace, pubkey) in params.packageOwnership) { for ((namespace, pubkey) in params.packageOwnership) {
// Note that due to the toLowerCase() call above, we'll be comparing against a lowercased // Note that due to the toLowerCase() call above, we'll be comparing against a lowercased
// version of the ownership claim. // version of the ownership claim.
val ns = namespace.toLowerCase(Locale.US) val ns = namespace.lowercase(Locale.US)
// We need an additional . to avoid matching com.foo.Widget against com.foobar.Zap // We need an additional . to avoid matching com.foo.Widget against com.foobar.Zap
if (pkgName == ns || pkgName.startsWith("$ns.")) { if (pkgName == ns || pkgName.startsWith("$ns.")) {
if (pubkey !in signers) if (pubkey !in signers)
@ -358,7 +351,7 @@ object AttachmentsClassLoaderBuilder {
val attachmentIds = attachments.mapTo(LinkedHashSet(), Attachment::id) val attachmentIds = attachments.mapTo(LinkedHashSet(), Attachment::id)
val cache = attachmentsClassLoaderCache ?: fallBackCache val cache = attachmentsClassLoaderCache ?: fallBackCache
val cachedSerializationContext = cache.computeIfAbsent(AttachmentsClassLoaderKey(attachmentIds, params), Function { key -> val cachedSerializationContext = cache.computeIfAbsent(AttachmentsClassLoaderKey(attachmentIds, params)) { key ->
// Create classloader and load serializers, whitelisted classes // Create classloader and load serializers, whitelisted classes
val transactionClassLoader = AttachmentsClassLoader(attachments, key.params, txId, isAttachmentTrusted, parent) val transactionClassLoader = AttachmentsClassLoader(attachments, key.params, txId, isAttachmentTrusted, parent)
val serializers = try { val serializers = try {
@ -380,9 +373,9 @@ object AttachmentsClassLoaderBuilder {
.withWhitelist(whitelistedClasses) .withWhitelist(whitelistedClasses)
.withCustomSerializers(serializers) .withCustomSerializers(serializers)
.withoutCarpenter() .withoutCarpenter()
}) }
val serializationContext = cachedSerializationContext.withProperties(mapOf<Any, Any>( val serializationContext = cachedSerializationContext.withProperties(mapOf(
// Duplicate the SerializationContext from the cache and give // Duplicate the SerializationContext from the cache and give
// it these extra properties, just for this transaction. // it these extra properties, just for this transaction.
// However, keep a strong reference to the cached SerializationContext so we can // However, keep a strong reference to the cached SerializationContext so we can
@ -489,7 +482,6 @@ class AttachmentsClassLoaderCacheImpl(cacheFactory: NamedCacheFactory) : Singlet
private val toBeClosed = ConcurrentHashMap.newKeySet<ToBeClosed>() private val toBeClosed = ConcurrentHashMap.newKeySet<ToBeClosed>()
private val expiryQueue = ReferenceQueue<SerializationContext>() private val expiryQueue = ReferenceQueue<SerializationContext>()
@Suppress("TooGenericExceptionCaught")
private fun purgeExpiryQueue() { private fun purgeExpiryQueue() {
// Close the AttachmentsClassLoader for every SerializationContext // Close the AttachmentsClassLoader for every SerializationContext
// that has already been garbage-collected. // that has already been garbage-collected.

View File

@ -290,7 +290,6 @@ private constructor(
// upgraded attachments // upgraded attachments
@CordaInternal @CordaInternal
@JvmSynthetic @JvmSynthetic
@Suppress("TooGenericExceptionCaught")
internal fun loadUpgradedContract(className: ContractClassName, id: SecureHash, classLoader: ClassLoader): UpgradedContract<ContractState, *> { internal fun loadUpgradedContract(className: ContractClassName, id: SecureHash, classLoader: ClassLoader): UpgradedContract<ContractState, *> {
return try { return try {
loadClassOfType<UpgradedContract<ContractState, *>>(className, false, classLoader) loadClassOfType<UpgradedContract<ContractState, *>>(className, false, classLoader)

View File

@ -943,17 +943,17 @@ class CryptoUtilsTest {
Security.removeProvider(CordaSecurityProvider.PROVIDER_NAME) Security.removeProvider(CordaSecurityProvider.PROVIDER_NAME)
// Try after removing CordaSecurityProvider. // Try after removing CordaSecurityProvider.
val secureRandomNotRegisteredCordaProvider = SecureRandom() val secureRandomNotRegisteredCordaProvider = SecureRandom()
assertNotEquals(PlatformSecureRandomService.algorithm, secureRandomNotRegisteredCordaProvider.algorithm) assertNotEquals(PlatformSecureRandomService.ALGORITHM, secureRandomNotRegisteredCordaProvider.algorithm)
// Now register CordaSecurityProvider as last Provider. // Now register CordaSecurityProvider as last Provider.
Security.addProvider(CordaSecurityProvider()) Security.addProvider(CordaSecurityProvider())
val secureRandomRegisteredLastCordaProvider = SecureRandom() val secureRandomRegisteredLastCordaProvider = SecureRandom()
assertNotEquals(PlatformSecureRandomService.algorithm, secureRandomRegisteredLastCordaProvider.algorithm) assertNotEquals(PlatformSecureRandomService.ALGORITHM, secureRandomRegisteredLastCordaProvider.algorithm)
// Remove Corda Provider again and add it as the first Provider entry. // Remove Corda Provider again and add it as the first Provider entry.
Security.removeProvider(CordaSecurityProvider.PROVIDER_NAME) Security.removeProvider(CordaSecurityProvider.PROVIDER_NAME)
Security.insertProviderAt(CordaSecurityProvider(), 1) // This is base-1. Security.insertProviderAt(CordaSecurityProvider(), 1) // This is base-1.
val secureRandomRegisteredFirstCordaProvider = SecureRandom() val secureRandomRegisteredFirstCordaProvider = SecureRandom()
assertEquals(PlatformSecureRandomService.algorithm, secureRandomRegisteredFirstCordaProvider.algorithm) assertEquals(PlatformSecureRandomService.ALGORITHM, secureRandomRegisteredFirstCordaProvider.algorithm)
} }
} }

View File

@ -1393,179 +1393,6 @@
<ID>ThrowsCount:TransactionVerifierServiceInternal.kt$Verifier$ private fun getUniqueContractAttachmentsByContract(): Map&lt;ContractClassName, ContractAttachment&gt;</ID> <ID>ThrowsCount:TransactionVerifierServiceInternal.kt$Verifier$ private fun getUniqueContractAttachmentsByContract(): Map&lt;ContractClassName, ContractAttachment&gt;</ID>
<ID>ThrowsCount:TransactionVerifierServiceInternal.kt$Verifier$// Using basic graph theory, a full cycle of encumbered (co-dependent) states should exist to achieve bi-directional // encumbrances. This property is important to ensure that no states involved in an encumbrance-relationship // can be spent on their own. Briefly, if any of the states is having more than one encumbrance references by // other states, a full cycle detection will fail. As a result, all of the encumbered states must be present // as "from" and "to" only once (or zero times if no encumbrance takes place). For instance, // a -&gt; b // c -&gt; b and a -&gt; b // b -&gt; a b -&gt; c // do not satisfy the bi-directionality (full cycle) property. // // In the first example "b" appears twice in encumbrance ("to") list and "c" exists in the encumbered ("from") list only. // Due the above, one could consume "a" and "b" in the same transaction and then, because "b" is already consumed, "c" cannot be spent. // // Similarly, the second example does not form a full cycle because "a" and "c" exist in one of the lists only. // As a result, one can consume "b" and "c" in the same transactions, which will make "a" impossible to be spent. // // On other hand the following are valid constructions: // a -&gt; b a -&gt; c // b -&gt; c and c -&gt; b // c -&gt; a b -&gt; a // and form a full cycle, meaning that the bi-directionality property is satisfied. private fun checkBidirectionalOutputEncumbrances(statesAndEncumbrance: List&lt;Pair&lt;Int, Int&gt;&gt;)</ID> <ID>ThrowsCount:TransactionVerifierServiceInternal.kt$Verifier$// Using basic graph theory, a full cycle of encumbered (co-dependent) states should exist to achieve bi-directional // encumbrances. This property is important to ensure that no states involved in an encumbrance-relationship // can be spent on their own. Briefly, if any of the states is having more than one encumbrance references by // other states, a full cycle detection will fail. As a result, all of the encumbered states must be present // as "from" and "to" only once (or zero times if no encumbrance takes place). For instance, // a -&gt; b // c -&gt; b and a -&gt; b // b -&gt; a b -&gt; c // do not satisfy the bi-directionality (full cycle) property. // // In the first example "b" appears twice in encumbrance ("to") list and "c" exists in the encumbered ("from") list only. // Due the above, one could consume "a" and "b" in the same transaction and then, because "b" is already consumed, "c" cannot be spent. // // Similarly, the second example does not form a full cycle because "a" and "c" exist in one of the lists only. // As a result, one can consume "b" and "c" in the same transactions, which will make "a" impossible to be spent. // // On other hand the following are valid constructions: // a -&gt; b a -&gt; c // b -&gt; c and c -&gt; b // c -&gt; a b -&gt; a // and form a full cycle, meaning that the bi-directionality property is satisfied. private fun checkBidirectionalOutputEncumbrances(statesAndEncumbrance: List&lt;Pair&lt;Int, Int&gt;&gt;)</ID>
<ID>ThrowsCount:WireTransaction.kt$WireTransaction.Companion$ @CordaInternal fun resolveStateRefBinaryComponent(stateRef: StateRef, services: ServicesForResolution): SerializedBytes&lt;TransactionState&lt;ContractState&gt;&gt;?</ID> <ID>ThrowsCount:WireTransaction.kt$WireTransaction.Companion$ @CordaInternal fun resolveStateRefBinaryComponent(stateRef: StateRef, services: ServicesForResolution): SerializedBytes&lt;TransactionState&lt;ContractState&gt;&gt;?</ID>
<ID>TooGenericExceptionCaught:AMQPChannelHandler.kt$AMQPChannelHandler$ex: Exception</ID>
<ID>TooGenericExceptionCaught:AMQPExceptions.kt$th: Throwable</ID>
<ID>TooGenericExceptionCaught:AMQPTestUtils.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:AbstractNode.kt$AbstractNode$e: Exception</ID>
<ID>TooGenericExceptionCaught:AbstractNode.kt$AbstractNode.&lt;no name provided&gt;$e: Exception</ID>
<ID>TooGenericExceptionCaught:AbstractNode.kt$ex: Exception</ID>
<ID>TooGenericExceptionCaught:AbstractNodeTests.kt$ColdJVM.Companion$t: Throwable</ID>
<ID>TooGenericExceptionCaught:Amount.kt$Amount.Companion$e: Exception</ID>
<ID>TooGenericExceptionCaught:ArtemisRpcBroker.kt$ArtemisRpcBroker$th: Throwable</ID>
<ID>TooGenericExceptionCaught:AttachmentDemo.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:AttachmentLoadingTests.kt$AttachmentLoadingTests.ConsumeAndBroadcastResponderFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:AttachmentVersionNumberMigration.kt$AttachmentVersionNumberMigration$e: Exception</ID>
<ID>TooGenericExceptionCaught:AzureSmbVolume.kt$AzureSmbVolume$e: Exception</ID>
<ID>TooGenericExceptionCaught:BCCryptoService.kt$BCCryptoService$e: Exception</ID>
<ID>TooGenericExceptionCaught:BankOfCordaWebApi.kt$BankOfCordaWebApi$e: Exception</ID>
<ID>TooGenericExceptionCaught:BlobInspector.kt$BlobInspector$e: Exception</ID>
<ID>TooGenericExceptionCaught:BootstrapperView.kt$BootstrapperView$e: Exception</ID>
<ID>TooGenericExceptionCaught:BrokerJaasLoginModule.kt$BrokerJaasLoginModule$e: Exception</ID>
<ID>TooGenericExceptionCaught:CertRole.kt$CertRole.Companion$ex: ArrayIndexOutOfBoundsException</ID>
<ID>TooGenericExceptionCaught:CheckpointAgent.kt$CheckpointAgent.Companion$e: Exception</ID>
<ID>TooGenericExceptionCaught:CheckpointAgent.kt$CheckpointHook$throwable: Throwable</ID>
<ID>TooGenericExceptionCaught:CheckpointDumperImpl.kt$CheckpointDumperImpl$e: Exception</ID>
<ID>TooGenericExceptionCaught:CheckpointVerifier.kt$CheckpointVerifier$e: Exception</ID>
<ID>TooGenericExceptionCaught:CollectSignaturesFlow.kt$SignTransactionFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:ConcurrencyUtils.kt$t: Throwable</ID>
<ID>TooGenericExceptionCaught:ConfigUtilities.kt$e:Exception</ID>
<ID>TooGenericExceptionCaught:ConnectionStateMachine.kt$ConnectionStateMachine$ex: Exception</ID>
<ID>TooGenericExceptionCaught:ContractAttachmentSerializer.kt$ContractAttachmentSerializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:ContractUpgradeTransactions.kt$ContractUpgradeWireTransaction$e: Exception</ID>
<ID>TooGenericExceptionCaught:CordaAuthenticationPlugin.kt$CordaAuthenticationPlugin$e: Exception</ID>
<ID>TooGenericExceptionCaught:CordaClassResolver.kt$LoggingWhitelist.Companion$ioEx: Exception</ID>
<ID>TooGenericExceptionCaught:CordaPersistence.kt$CordaPersistence$e: Exception</ID>
<ID>TooGenericExceptionCaught:CordaRPCClientTest.kt$CordaRPCClientTest$e: Exception</ID>
<ID>TooGenericExceptionCaught:CordaRPCOpsImpl.kt$CordaRPCOpsImpl$e: Exception</ID>
<ID>TooGenericExceptionCaught:CordaServiceLifecycleFatalTests.kt$CordaServiceLifecycleFatalTests$ex: Exception</ID>
<ID>TooGenericExceptionCaught:CryptoUtilsTest.kt$CryptoUtilsTest$e: Exception</ID>
<ID>TooGenericExceptionCaught:DBNetworkParametersStorage.kt$DBNetworkParametersStorage$e: Exception</ID>
<ID>TooGenericExceptionCaught:DataUploadServlet.kt$DataUploadServlet$e: RuntimeException</ID>
<ID>TooGenericExceptionCaught:DbMapDeadlockTest.kt$DbMapDeadlockTest$e: Exception</ID>
<ID>TooGenericExceptionCaught:DemoBenchView.kt$DemoBenchView$e: Exception</ID>
<ID>TooGenericExceptionCaught:DeserializationInput.kt$DeserializationInput$e: Exception</ID>
<ID>TooGenericExceptionCaught:DeserializeSimpleTypesTests.kt$DeserializeSimpleTypesTests$e: Exception</ID>
<ID>TooGenericExceptionCaught:DistributionMux.kt$DistributionMux$ex: Exception</ID>
<ID>TooGenericExceptionCaught:DockerInstantiator.kt$DockerInstantiator$e: Exception</ID>
<ID>TooGenericExceptionCaught:DriverDSLImpl.kt$DriverDSLImpl$e: Exception</ID>
<ID>TooGenericExceptionCaught:DriverDSLImpl.kt$DriverDSLImpl.Companion$th: Throwable</ID>
<ID>TooGenericExceptionCaught:DriverDSLImpl.kt$exception: Throwable</ID>
<ID>TooGenericExceptionCaught:DriverTests.kt$DriverTests$e: Exception</ID>
<ID>TooGenericExceptionCaught:ErrorHandling.kt$ErrorHandling.CheckpointAfterErrorFlow$t: Throwable</ID>
<ID>TooGenericExceptionCaught:EventProcessor.kt$EventProcessor$ex: Exception</ID>
<ID>TooGenericExceptionCaught:Eventually.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:Expect.kt$exception: Exception</ID>
<ID>TooGenericExceptionCaught:Explorer.kt$Explorer$e: Exception</ID>
<ID>TooGenericExceptionCaught:FinanceJSONSupport.kt$CalendarDeserializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:FlowHandle.kt$FlowProgressHandleImpl$e: Exception</ID>
<ID>TooGenericExceptionCaught:FlowMessaging.kt$FlowMessagingImpl$exception: Exception</ID>
<ID>TooGenericExceptionCaught:FlowStackSnapshotTest.kt$FlowStackSnapshotTest$exception: Exception</ID>
<ID>TooGenericExceptionCaught:FlowStateMachineImpl.kt$FlowStateMachineImpl$exception: Exception</ID>
<ID>TooGenericExceptionCaught:FlowStateMachineImpl.kt$FlowStateMachineImpl$t: Throwable</ID>
<ID>TooGenericExceptionCaught:FutureMatchers.kt$&lt;no name provided&gt;$e: Exception</ID>
<ID>TooGenericExceptionCaught:HibernateConfiguration.kt$HibernateConfiguration$e: Exception</ID>
<ID>TooGenericExceptionCaught:HibernateQueryCriteriaParser.kt$HibernateQueryCriteriaParser$e: Exception</ID>
<ID>TooGenericExceptionCaught:IRSDemo.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:IRSDemoTest.kt$IRSDemoTest.InterestRateSwapStateDeserializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:InitialRegistrationCli.kt$InitialRegistration$e: Exception</ID>
<ID>TooGenericExceptionCaught:InitialRegistrationCli.kt$InitialRegistration.Companion$e: Exception</ID>
<ID>TooGenericExceptionCaught:Injectors.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:InstallShellExtensionsParser.kt$ShellExtensionsGenerator$exception: Exception</ID>
<ID>TooGenericExceptionCaught:InteractiveShell.kt$InteractiveShell$e: Exception</ID>
<ID>TooGenericExceptionCaught:InteractiveShell.kt$InteractiveShell$e: IndexOutOfBoundsException</ID>
<ID>TooGenericExceptionCaught:InterestSwapRestAPI.kt$InterestRateSwapAPI$ex: Exception</ID>
<ID>TooGenericExceptionCaught:InternalMockNetwork.kt$InternalMockNetwork$t: Throwable</ID>
<ID>TooGenericExceptionCaught:InternalTestUtils.kt$&lt;no name provided&gt;$e: Exception</ID>
<ID>TooGenericExceptionCaught:InternalUtils.kt$ex: Exception</ID>
<ID>TooGenericExceptionCaught:InternalUtils.kt$th: Throwable</ID>
<ID>TooGenericExceptionCaught:IssueCash.kt$IssueCash$e: Exception</ID>
<ID>TooGenericExceptionCaught:JacksonSupport.kt$JacksonSupport.PartyDeserializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:JacksonSupport.kt$JacksonSupport.PublicKeyDeserializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:JacksonSupport.kt$JacksonSupport.SecureHashDeserializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:JarScanningCordappLoader.kt$JarScanningCordappLoader$e: Exception</ID>
<ID>TooGenericExceptionCaught:Kryo.kt$ImmutableClassSerializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:LedgerDSLInterpreter.kt$Verifies$exception: Exception</ID>
<ID>TooGenericExceptionCaught:LoadTest.kt$LoadTest$throwable: Throwable</ID>
<ID>TooGenericExceptionCaught:LoginView.kt$LoginView$e: Exception</ID>
<ID>TooGenericExceptionCaught:Main.kt$Main$e: Exception</ID>
<ID>TooGenericExceptionCaught:MerkleTransaction.kt$FilteredTransaction$e: Exception</ID>
<ID>TooGenericExceptionCaught:MigrationServicesForResolution.kt$MigrationServicesForResolution$e: Exception</ID>
<ID>TooGenericExceptionCaught:MockAttachmentStorage.kt$MockAttachmentStorage$e: Exception</ID>
<ID>TooGenericExceptionCaught:MockCryptoService.kt$MockCryptoService$e: Exception</ID>
<ID>TooGenericExceptionCaught:MockNodeMessagingService.kt$MockNodeMessagingService$e: Exception</ID>
<ID>TooGenericExceptionCaught:MultiRPCClient.kt$MultiRPCClient$ex: Throwable</ID>
<ID>TooGenericExceptionCaught:MyCustomNotaryService.kt$MyValidatingNotaryFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:NamedCacheTest.kt$NamedCacheTest$e: Exception</ID>
<ID>TooGenericExceptionCaught:NettyTestHandler.kt$NettyTestHandler$e: Throwable</ID>
<ID>TooGenericExceptionCaught:NetworkBootstrapper.kt$NetworkBootstrapper$e: Exception</ID>
<ID>TooGenericExceptionCaught:NetworkMapServer.kt$NetworkMapServer.InMemoryNetworkMapService$e: Exception</ID>
<ID>TooGenericExceptionCaught:NetworkMapUpdater.kt$NetworkMapUpdater$e: Exception</ID>
<ID>TooGenericExceptionCaught:NetworkMapUpdater.kt$NetworkMapUpdater.&lt;no name provided&gt;$e: Exception</ID>
<ID>TooGenericExceptionCaught:NetworkParameterOverridesSpec.kt$NetworkParameterOverridesSpec.PackageOwnershipSpec$e: Exception</ID>
<ID>TooGenericExceptionCaught:NetworkParametersReader.kt$NetworkParametersReader$e: Exception</ID>
<ID>TooGenericExceptionCaught:NetworkRegistrationHelper.kt$NetworkRegistrationHelper$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeController.kt$NodeController$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeInfoWatcher.kt$NodeInfoWatcher$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeInterestRates.kt$NodeInterestRates$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeMonitorModel.kt$NodeMonitorModel$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeProcess.kt$NodeProcess.Factory$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeRPC.kt$NodeRPC$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeRPC.kt$NodeRPC.&lt;no name provided&gt;$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeSchedulerService.kt$NodeSchedulerService$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeStartup.kt$NodeStartup$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeTerminalView.kt$NodeTerminalView$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeVaultService.kt$NodeVaultService$e: Exception</ID>
<ID>TooGenericExceptionCaught:NodeVaultServiceTest.kt$NodeVaultServiceTest$e: Exception</ID>
<ID>TooGenericExceptionCaught:NonValidatingNotaryFlow.kt$NonValidatingNotaryFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:NotaryServiceFlow.kt$NotaryServiceFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:NotaryUtils.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:ObjectDiffer.kt$ObjectDiffer$throwable: Exception</ID>
<ID>TooGenericExceptionCaught:P2PMessagingClient.kt$P2PMessagingClient$e: Exception</ID>
<ID>TooGenericExceptionCaught:PersistentUniquenessProvider.kt$PersistentUniquenessProvider$e: Exception</ID>
<ID>TooGenericExceptionCaught:ProfileController.kt$ProfileController$e: Exception</ID>
<ID>TooGenericExceptionCaught:PropertyValidationTest.kt$PropertyValidationTest$e: Exception</ID>
<ID>TooGenericExceptionCaught:QuasarInstrumentationHook.kt$QuasarInstrumentationHook$throwable: Throwable</ID>
<ID>TooGenericExceptionCaught:R3Pty.kt$R3Pty$e: Exception</ID>
<ID>TooGenericExceptionCaught:RPCApi.kt$RPCApi.ServerToClient.Companion$e: Exception</ID>
<ID>TooGenericExceptionCaught:RPCClient.kt$RPCClient$throwable: Throwable</ID>
<ID>TooGenericExceptionCaught:RPCClientProxyHandler.kt$RPCClientProxyHandler$e: Exception</ID>
<ID>TooGenericExceptionCaught:RPCClientProxyHandler.kt$RPCClientProxyHandler$e: RuntimeException</ID>
<ID>TooGenericExceptionCaught:RPCPermissionResolver.kt$RPCPermissionResolver.InterfaceMethodMapCacheLoader$ex: Exception</ID>
<ID>TooGenericExceptionCaught:RPCServer.kt$RPCServer$e: Exception</ID>
<ID>TooGenericExceptionCaught:RPCServer.kt$RPCServer$exception: Throwable</ID>
<ID>TooGenericExceptionCaught:RPCServer.kt$RPCServer$throwable: Throwable</ID>
<ID>TooGenericExceptionCaught:RPCStabilityTests.kt$RPCStabilityTests$e2: Exception</ID>
<ID>TooGenericExceptionCaught:RPCStabilityTests.kt$RPCStabilityTests$e: Exception</ID>
<ID>TooGenericExceptionCaught:RandomFailingProxy.kt$RandomFailingProxy$e: Exception</ID>
<ID>TooGenericExceptionCaught:ReceiveTransactionFlow.kt$ReceiveTransactionFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:ReconnectingCordaRPCOps.kt$ReconnectingCordaRPCOps.ReconnectingRPCConnection$ex: Exception</ID>
<ID>TooGenericExceptionCaught:ReconnectingObservable.kt$ReconnectingObservable.ReconnectingSubscriber$e: Exception</ID>
<ID>TooGenericExceptionCaught:RpcServerObservableSerializerTests.kt$RpcServerObservableSerializerTests$e: Exception</ID>
<ID>TooGenericExceptionCaught:SSLHelper.kt$ex: Exception</ID>
<ID>TooGenericExceptionCaught:SerializationOutputTests.kt$SerializationOutputTests$t: Throwable</ID>
<ID>TooGenericExceptionCaught:ShutdownManager.kt$ShutdownManager$t: Throwable</ID>
<ID>TooGenericExceptionCaught:SimpleAMQPClient.kt$SimpleAMQPClient$e: Exception</ID>
<ID>TooGenericExceptionCaught:SimpleMQClient.kt$SimpleMQClient$e: Exception</ID>
<ID>TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$e: Exception</ID>
<ID>TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$ex: Exception</ID>
<ID>TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$exception: Exception</ID>
<ID>TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$t: Throwable</ID>
<ID>TooGenericExceptionCaught:StandaloneShell.kt$StandaloneShell$e: Exception</ID>
<ID>TooGenericExceptionCaught:StandardConfigValueParsers.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:StringToMethodCallParser.kt$StringToMethodCallParser$e: Exception</ID>
<ID>TooGenericExceptionCaught:TLSAuthenticationTests.kt$TLSAuthenticationTests$ex: Exception</ID>
<ID>TooGenericExceptionCaught:ThrowableSerializer.kt$ThrowableSerializer$e: Exception</ID>
<ID>TooGenericExceptionCaught:TlsDiffAlgorithmsTest.kt$TlsDiffAlgorithmsTest$ex: Exception</ID>
<ID>TooGenericExceptionCaught:TlsDiffProtocolsTest.kt$TlsDiffProtocolsTest$ex: Exception</ID>
<ID>TooGenericExceptionCaught:TraderDemo.kt$TraderDemo$e: Exception</ID>
<ID>TooGenericExceptionCaught:TransactionBuilder.kt$TransactionBuilder$e: Throwable</ID>
<ID>TooGenericExceptionCaught:TransactionSignatureTest.kt$TransactionSignatureTest$e: Throwable</ID>
<ID>TooGenericExceptionCaught:TransactionUtils.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:TransformTypes.kt$TransformTypes.Companion$e: IndexOutOfBoundsException</ID>
<ID>TooGenericExceptionCaught:TransitionExecutorImpl.kt$TransitionExecutorImpl$exception: Exception</ID>
<ID>TooGenericExceptionCaught:Try.kt$Try.Companion$t: Throwable</ID>
<ID>TooGenericExceptionCaught:UserValidationPlugin.kt$UserValidationPlugin$e: Throwable</ID>
<ID>TooGenericExceptionCaught:Utils.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:V1NodeConfigurationSpec.kt$V1NodeConfigurationSpec$e: Exception</ID>
<ID>TooGenericExceptionCaught:ValidatingNotaryFlow.kt$ValidatingNotaryFlow$e: Exception</ID>
<ID>TooGenericExceptionCaught:VaultStateMigration.kt$VaultStateIterator$e: Exception</ID>
<ID>TooGenericExceptionCaught:VaultStateMigration.kt$VaultStateMigration$e: Exception</ID>
<ID>TooGenericExceptionCaught:WebServer.kt$WebServer$e: Exception</ID>
<ID>TooGenericExceptionCaught:WebServer.kt$e: Exception</ID>
<ID>TooGenericExceptionCaught:WebServer.kt$ex: Exception</ID>
<ID>TooGenericExceptionCaught:WithMockNet.kt$WithMockNet.&lt;no name provided&gt;$e: Exception</ID>
<ID>TooGenericExceptionCaught:X509EdDSAEngine.kt$X509EdDSAEngine$e: Exception</ID>
<ID>TooGenericExceptionCaught:X509UtilitiesTest.kt$X509UtilitiesTest$ex: Exception</ID>
<ID>TooGenericExceptionThrown:AMQPExceptionsTests.kt$AMQPExceptionsTests$throw Exception("FAILED")</ID> <ID>TooGenericExceptionThrown:AMQPExceptionsTests.kt$AMQPExceptionsTests$throw Exception("FAILED")</ID>
<ID>TooGenericExceptionThrown:AzureBackend.kt$AzureBackend.Companion$throw RuntimeException(e)</ID> <ID>TooGenericExceptionThrown:AzureBackend.kt$AzureBackend.Companion$throw RuntimeException(e)</ID>
<ID>TooGenericExceptionThrown:ClassLoadingUtilsTest.kt$ClassLoadingUtilsTest$throw RuntimeException()</ID> <ID>TooGenericExceptionThrown:ClassLoadingUtilsTest.kt$ClassLoadingUtilsTest$throw RuntimeException()</ID>

View File

@ -77,17 +77,6 @@ empty-blocks:
exceptions: exceptions:
active: true active: true
excludes: "**/buildSrc/**" excludes: "**/buildSrc/**"
TooGenericExceptionCaught:
active: true
exceptionNames:
- ArrayIndexOutOfBoundsException
- Error
- Exception
- IllegalMonitorStateException
- NullPointerException
- IndexOutOfBoundsException
- RuntimeException
- Throwable
TooGenericExceptionThrown: TooGenericExceptionThrown:
active: true active: true
exceptionNames: exceptionNames:

View File

@ -1,4 +1,3 @@
@file:Suppress("TooGenericExceptionCaught") // needs to catch and handle/rethrow *all* exceptions in many places
package net.corda.nodeapi.internal.bridging package net.corda.nodeapi.internal.bridging
import co.paralleluniverse.fibers.instrument.DontInstrument import co.paralleluniverse.fibers.instrument.DontInstrument

View File

@ -1,4 +1,3 @@
@file:Suppress("TooGenericExceptionCaught") // needs to catch and handle/rethrow *all* exceptions
package net.corda.nodeapi.internal.bridging package net.corda.nodeapi.internal.bridging
import net.corda.core.identity.CordaX500Name import net.corda.core.identity.CordaX500Name
@ -27,6 +26,7 @@ import rx.Observable
import rx.subjects.PublishSubject import rx.subjects.PublishSubject
import java.time.Duration import java.time.Duration
import java.util.* import java.util.*
import kotlin.system.exitProcess
class BridgeControlListener(private val keyStore: CertificateStore, class BridgeControlListener(private val keyStore: CertificateStore,
trustStore: CertificateStore, trustStore: CertificateStore,
@ -142,7 +142,7 @@ class BridgeControlListener(private val keyStore: CertificateStore,
val notifyMessage = data.deserialize<BridgeControl.BridgeToNodeSnapshotRequest>(context = SerializationDefaults.P2P_CONTEXT) val notifyMessage = data.deserialize<BridgeControl.BridgeToNodeSnapshotRequest>(context = SerializationDefaults.P2P_CONTEXT)
if (notifyMessage.bridgeIdentity != bridgeId) { if (notifyMessage.bridgeIdentity != bridgeId) {
log.error("Fatal Error! Two bridges have been configured simultaneously! Check the enterpriseConfiguration.externalBridge status") log.error("Fatal Error! Two bridges have been configured simultaneously! Check the enterpriseConfiguration.externalBridge status")
System.exit(1) exitProcess(1)
} }
} catch (ex: Exception) { } catch (ex: Exception) {
log.error("Unable to process bridge notification message", ex) log.error("Unable to process bridge notification message", ex)
@ -204,7 +204,7 @@ class BridgeControlListener(private val keyStore: CertificateStore,
is BridgeControl.NodeToBridgeSnapshot -> { is BridgeControl.NodeToBridgeSnapshot -> {
if (!isConfigured(controlMessage.nodeIdentity)) { if (!isConfigured(controlMessage.nodeIdentity)) {
log.error("Fatal error! Bridge not configured with keystore for node with legal name ${controlMessage.nodeIdentity}.") log.error("Fatal error! Bridge not configured with keystore for node with legal name ${controlMessage.nodeIdentity}.")
System.exit(1) exitProcess(1)
} }
if (!controlMessage.inboxQueues.all { validateInboxQueueName(it) }) { if (!controlMessage.inboxQueues.all { validateInboxQueueName(it) }) {
log.error("Invalid queue names in control message $controlMessage") log.error("Invalid queue names in control message $controlMessage")

View File

@ -1,4 +1,4 @@
@file:Suppress("MagicNumber", "TooGenericExceptionCaught") @file:Suppress("MagicNumber")
package net.corda.nodeapi.internal.crypto package net.corda.nodeapi.internal.crypto

View File

@ -5,7 +5,6 @@ import com.github.benmanes.caffeine.cache.LoadingCache
import net.corda.core.internal.readFully import net.corda.core.internal.readFully
import net.corda.core.utilities.contextLogger import net.corda.core.utilities.contextLogger
import net.corda.core.utilities.debug import net.corda.core.utilities.debug
import net.corda.core.utilities.contextLogger
import net.corda.core.utilities.minutes import net.corda.core.utilities.minutes
import net.corda.core.utilities.seconds import net.corda.core.utilities.seconds
import net.corda.nodeapi.internal.crypto.X509CertificateFactory import net.corda.nodeapi.internal.crypto.X509CertificateFactory
@ -21,7 +20,6 @@ import javax.security.auth.x500.X500Principal
/** /**
* [CrlSource] which downloads CRLs from the distribution points in the X509 certificate and caches them. * [CrlSource] which downloads CRLs from the distribution points in the X509 certificate and caches them.
*/ */
@Suppress("TooGenericExceptionCaught")
class CertDistPointCrlSource(cacheSize: Long = DEFAULT_CACHE_SIZE, class CertDistPointCrlSource(cacheSize: Long = DEFAULT_CACHE_SIZE,
cacheExpiry: Duration = DEFAULT_CACHE_EXPIRY, cacheExpiry: Duration = DEFAULT_CACHE_EXPIRY,
private val connectTimeout: Duration = DEFAULT_CONNECT_TIMEOUT, private val connectTimeout: Duration = DEFAULT_CONNECT_TIMEOUT,

View File

@ -33,7 +33,6 @@ class CordaRevocationChecker(private val crlSource: CrlSource,
checkApprovedCRLs(cert, getCRLs(cert)) checkApprovedCRLs(cert, getCRLs(cert))
} }
@Suppress("TooGenericExceptionCaught")
private fun getCRLs(cert: X509Certificate): Set<X509CRL> { private fun getCRLs(cert: X509Certificate): Set<X509CRL> {
val crls = try { val crls = try {
crlSource.fetch(cert) crlSource.fetch(cert)

View File

@ -705,7 +705,6 @@ class StateMachineGeneralErrorHandlingTest : StateMachineErrorHandlingTest() {
* *
* On shutdown this flow will still terminate correctly and not prevent the node from shutting down. * On shutdown this flow will still terminate correctly and not prevent the node from shutting down.
*/ */
@Suppress("TooGenericExceptionCaught")
@Test(timeout = 300_000) @Test(timeout = 300_000)
fun `a dead flow can be shutdown`() { fun `a dead flow can be shutdown`() {
startDriver { startDriver {

View File

@ -213,7 +213,6 @@ class ProtonWrapperTests {
assertTrue(done) assertTrue(done)
} }
@Suppress("TooGenericExceptionCaught") // Too generic exception thrown!
@Test(timeout=300_000) @Test(timeout=300_000)
fun `AMPQClient that fails to handshake with a server will retry the server`() { fun `AMPQClient that fails to handshake with a server will retry the server`() {
/* /*

View File

@ -42,7 +42,7 @@ import java.util.concurrent.Semaphore
import javax.persistence.PersistenceException import javax.persistence.PersistenceException
import kotlin.test.assertEquals import kotlin.test.assertEquals
@Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown") @Suppress("TooGenericExceptionThrown")
class FlowEntityManagerTest : AbstractFlowEntityManagerTest() { class FlowEntityManagerTest : AbstractFlowEntityManagerTest() {
@Before @Before

View File

@ -139,7 +139,7 @@ class FlowHospitalTest {
@Test(timeout = 300_000) @Test(timeout = 300_000)
fun `HospitalizeFlowException thrown`() { fun `HospitalizeFlowException thrown`() {
var observationCounter: Int = 0 var observationCounter = 0
StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ -> StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ ->
++observationCounter ++observationCounter
} }
@ -161,7 +161,7 @@ class FlowHospitalTest {
@Test(timeout = 300_000) @Test(timeout = 300_000)
fun `Custom exception wrapping HospitalizeFlowException thrown`() { fun `Custom exception wrapping HospitalizeFlowException thrown`() {
var observationCounter: Int = 0 var observationCounter = 0
StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ -> StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ ->
++observationCounter ++observationCounter
} }
@ -183,7 +183,7 @@ class FlowHospitalTest {
@Test(timeout = 300_000) @Test(timeout = 300_000)
fun `Custom exception extending HospitalizeFlowException thrown`() { fun `Custom exception extending HospitalizeFlowException thrown`() {
var observationCounter: Int = 0 var observationCounter = 0
StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ -> StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ ->
++observationCounter ++observationCounter
} }
@ -470,7 +470,7 @@ class FlowHospitalTest {
@Suspendable @Suspendable
override fun call() { override fun call() {
val throwable = hospitalizeFlowExceptionClass.newInstance() val throwable = hospitalizeFlowExceptionClass.getDeclaredConstructor().newInstance()
(throwable as? Throwable)?.let { (throwable as? Throwable)?.let {
throw it throw it
} }
@ -561,7 +561,6 @@ class FlowHospitalTest {
var exceptionSeenInUserFlow = false var exceptionSeenInUserFlow = false
} }
@Suppress("TooGenericExceptionCaught")
@Suspendable @Suspendable
override fun call() { override fun call() {
val consumeError = session.receive<Boolean>().unwrap { it } val consumeError = session.receive<Boolean>().unwrap { it }

View File

@ -1237,7 +1237,6 @@ abstract class AbstractNode<S>(val configuration: NodeConfiguration,
*/ */
override fun jdbcSession(): Connection = RestrictedConnection(database.createSession(), services) override fun jdbcSession(): Connection = RestrictedConnection(database.createSession(), services)
@Suppress("TooGenericExceptionCaught")
override fun <T : Any?> withEntityManager(block: EntityManager.() -> T): T { override fun <T : Any?> withEntityManager(block: EntityManager.() -> T): T {
return database.transaction(useErrorHandler = false) { return database.transaction(useErrorHandler = false) {
session.flush() session.flush()

View File

@ -51,7 +51,6 @@ import net.corda.node.services.config.shouldStartLocalShell
import net.corda.node.utilities.registration.NodeRegistrationException import net.corda.node.utilities.registration.NodeRegistrationException
import net.corda.nodeapi.internal.JVMAgentUtilities import net.corda.nodeapi.internal.JVMAgentUtilities
import net.corda.nodeapi.internal.addShutdownHook import net.corda.nodeapi.internal.addShutdownHook
import net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException
import net.corda.nodeapi.internal.persistence.DatabaseIncompatibleException import net.corda.nodeapi.internal.persistence.DatabaseIncompatibleException
import org.fusesource.jansi.Ansi import org.fusesource.jansi.Ansi
import org.slf4j.bridge.SLF4JBridgeHandler import org.slf4j.bridge.SLF4JBridgeHandler
@ -217,7 +216,7 @@ open class NodeStartup : NodeStartupLogging {
if (requireCertificates && !canReadCertificatesDirectory(configuration.certificatesDirectory, configuration.devMode)) return ExitCodes.FAILURE if (requireCertificates && !canReadCertificatesDirectory(configuration.certificatesDirectory, configuration.devMode)) return ExitCodes.FAILURE
// Step 7. Configuring special serialisation requirements, i.e., bft-smart relies on Java serialization. // Step 7. Configuring special serialisation requirements, i.e., bft-smart relies on Java serialization.
if (attempt { banJavaSerialisation(configuration) }.doOnFailure(Consumer { error -> error.logAsUnexpected("Exception while configuring serialisation") }) !is Try.Success) return ExitCodes.FAILURE if (attempt { banJavaSerialisation(configuration) }.doOnFailure { error -> error.logAsUnexpected("Exception while configuring serialisation") } !is Try.Success) return ExitCodes.FAILURE
// Step 8. Any actions required before starting up the Corda network layer. // Step 8. Any actions required before starting up the Corda network layer.
if (attempt { preNetworkRegistration(configuration) }.doOnFailure(Consumer(::handleRegistrationError)) !is Try.Success) return ExitCodes.FAILURE if (attempt { preNetworkRegistration(configuration) }.doOnFailure(Consumer(::handleRegistrationError)) !is Try.Success) return ExitCodes.FAILURE
@ -472,7 +471,6 @@ interface NodeStartupLogging {
companion object { companion object {
val logger by lazy { contextLogger() } val logger by lazy { contextLogger() }
val startupErrors = setOf(MultipleCordappsForFlowException::class, CheckpointIncompatibleException::class, AddressBindingException::class, NetworkParametersReader::class, DatabaseIncompatibleException::class) val startupErrors = setOf(MultipleCordappsForFlowException::class, CheckpointIncompatibleException::class, AddressBindingException::class, NetworkParametersReader::class, DatabaseIncompatibleException::class)
@Suppress("TooGenericExceptionCaught")
val PRINT_ERRORS_TO_STD_ERR = try { val PRINT_ERRORS_TO_STD_ERR = try {
System.getProperty("net.corda.node.printErrorsToStdErr") == "true" System.getProperty("net.corda.node.printErrorsToStdErr") == "true"
} catch (e: NullPointerException) { } catch (e: NullPointerException) {
@ -515,7 +513,6 @@ interface NodeStartupLogging {
when { when {
error is ErrorCode<*> -> logger.report(error) error is ErrorCode<*> -> logger.report(error)
error.isExpectedWhenStartingNode() -> error.logAsExpected() error.isExpectedWhenStartingNode() -> error.logAsExpected()
error is CouldNotCreateDataSourceException -> error.logAsUnexpected()
error is Errors.NativeIoException && error.message?.contains("Address already in use") == true -> error.logAsExpected("One of the ports required by the Corda node is already in use.") error is Errors.NativeIoException && error.message?.contains("Address already in use") == true -> error.logAsExpected("One of the ports required by the Corda node is already in use.")
error is Errors.NativeIoException && error.message?.contains("Can't assign requested address") == true -> error.logAsExpected("Exception during node startup. Check that addresses in node config resolve correctly.") error is Errors.NativeIoException && error.message?.contains("Can't assign requested address") == true -> error.logAsExpected("Exception during node startup. Check that addresses in node config resolve correctly.")
error is UnresolvedAddressException -> error.logAsExpected("Exception during node startup. Check that addresses in node config resolve correctly.") error is UnresolvedAddressException -> error.logAsExpected("Exception during node startup. Check that addresses in node config resolve correctly.")
@ -541,14 +538,14 @@ fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean {
try { try {
logPath.safeSymbolicRead().createDirectories() logPath.safeSymbolicRead().createDirectories()
} catch (e: IOException) { } catch (e: IOException) {
printError("Unable to create logging directory ${logPath.toString()}. Node will now shutdown.") printError("Unable to create logging directory $logPath. Node will now shutdown.")
return false return false
} catch (e: SecurityException) { } catch (e: SecurityException) {
printError("Current user is unable to access logging directory ${logPath.toString()}. Node will now shutdown.") printError("Current user is unable to access logging directory $logPath. Node will now shutdown.")
return false return false
} }
if (!logPath.isDirectory()) { if (!logPath.isDirectory()) {
printError("Unable to access logging directory ${logPath.toString()}. Node will now shutdown.") printError("Unable to access logging directory $logPath. Node will now shutdown.")
return false return false
} }

View File

@ -113,7 +113,6 @@ class ArtemisMessagingServer(private val config: NodeConfiguration,
registerPostQueueDeletionCallback { address, qName -> log.debug { "Queue deleted: $qName for $address" } } registerPostQueueDeletionCallback { address, qName -> log.debug { "Queue deleted: $qName for $address" } }
} }
@Suppress("TooGenericExceptionCaught")
try { try {
activeMQServer.startSynchronously() activeMQServer.startSynchronously()
} catch (e: Throwable) { } catch (e: Throwable) {

View File

@ -10,7 +10,6 @@ import java.io.DataOutputStream
import java.nio.ByteBuffer import java.nio.ByteBuffer
import java.time.Instant import java.time.Instant
@Suppress("TooGenericExceptionCaught")
@CordaSerializable @CordaSerializable
data class HashedDistributionList( data class HashedDistributionList(
val senderStatesToRecord: StatesToRecord, val senderStatesToRecord: StatesToRecord,
@ -60,7 +59,7 @@ data class HashedDistributionList(
fun unauthenticatedDeserialise(encryptedBytes: ByteArray, encryptionService: EncryptionService): PublicHeader { fun unauthenticatedDeserialise(encryptedBytes: ByteArray, encryptionService: EncryptionService): PublicHeader {
val additionalData = encryptionService.extractUnauthenticatedAdditionalData(encryptedBytes) val additionalData = encryptionService.extractUnauthenticatedAdditionalData(encryptedBytes)
requireNotNull(additionalData) { "Missing additional data field" } requireNotNull(additionalData) { "Missing additional data field" }
return deserialise(additionalData!!) return deserialise(additionalData)
} }
fun deserialise(bytes: ByteArray): PublicHeader { fun deserialise(bytes: ByteArray): PublicHeader {
@ -91,7 +90,7 @@ data class HashedDistributionList(
fun decrypt(encryptedBytes: ByteArray, encryptionService: EncryptionService): HashedDistributionList { fun decrypt(encryptedBytes: ByteArray, encryptionService: EncryptionService): HashedDistributionList {
val (plaintext, authenticatedAdditionalData) = encryptionService.decrypt(encryptedBytes) val (plaintext, authenticatedAdditionalData) = encryptionService.decrypt(encryptedBytes)
requireNotNull(authenticatedAdditionalData) { "Missing authenticated header" } requireNotNull(authenticatedAdditionalData) { "Missing authenticated header" }
val publicHeader = PublicHeader.deserialise(authenticatedAdditionalData!!) val publicHeader = PublicHeader.deserialise(authenticatedAdditionalData)
val input = DataInputStream(plaintext.inputStream()) val input = DataInputStream(plaintext.inputStream())
try { try {
val senderStatesToRecord = statesToRecordValues[input.readByte().toInt()] val senderStatesToRecord = statesToRecordValues[input.readByte().toInt()]

View File

@ -52,7 +52,6 @@ class ArtemisRpcBroker internal constructor(
} }
} }
@Suppress("TooGenericExceptionCaught")
override fun start() { override fun start() {
logger.debug { "Artemis RPC broker is starting for: $addresses" } logger.debug { "Artemis RPC broker is starting for: $addresses" }
try { try {
@ -90,7 +89,7 @@ class ArtemisRpcBroker internal constructor(
val serverSecurityManager = createArtemisSecurityManager(serverConfiguration.loginListener) val serverSecurityManager = createArtemisSecurityManager(serverConfiguration.loginListener)
return ActiveMQServerImpl(serverConfiguration, serverSecurityManager).apply { return ActiveMQServerImpl(serverConfiguration, serverSecurityManager).apply {
registerPostQueueDeletionCallback { address, qName -> logger.debug("Queue deleted: $qName for $address") } registerPostQueueDeletionCallback { address, qName -> logger.debug { "Queue deleted: $qName for $address" } }
} }
} }

View File

@ -107,7 +107,6 @@ class CheckpointDumperImpl(private val checkpointStorage: CheckpointStorage, pri
context: CheckpointSerializationContext, context: CheckpointSerializationContext,
runId: StateMachineRunId, runId: StateMachineRunId,
flowState: FlowState.Started) { flowState: FlowState.Started) {
@Suppress("TooGenericExceptionCaught")
try { try {
flowState.frozenFiber.checkpointDeserialize(context) flowState.frozenFiber.checkpointDeserialize(context)
} catch (e: Exception) { } catch (e: Exception) {

View File

@ -112,7 +112,6 @@ internal class ActionExecutorImpl(
} }
} }
@Suppress("TooGenericExceptionCaught") // this is fully intentional here, see comment in the catch clause
@Suspendable @Suspendable
private fun executeAcknowledgeMessages(action: Action.AcknowledgeMessages) { private fun executeAcknowledgeMessages(action: Action.AcknowledgeMessages) {
action.deduplicationHandlers.forEach { action.deduplicationHandlers.forEach {
@ -231,7 +230,6 @@ internal class ActionExecutorImpl(
action.currentState.run { numberOfCommits = checkpoint.checkpointState.numberOfCommits } action.currentState.run { numberOfCommits = checkpoint.checkpointState.numberOfCommits }
} }
@Suppress("TooGenericExceptionCaught")
@Suspendable @Suspendable
private fun executeAsyncOperation(fiber: FlowFiber, action: Action.ExecuteAsyncOperation) { private fun executeAsyncOperation(fiber: FlowFiber, action: Action.ExecuteAsyncOperation) {
try { try {

View File

@ -174,7 +174,6 @@ class FlowCreator(
return Flow(flowStateMachineImpl, resultFuture) return Flow(flowStateMachineImpl, resultFuture)
} }
@Suppress("TooGenericExceptionCaught")
private fun Checkpoint.getFiberFromCheckpoint(runId: StateMachineRunId, firstRestore: Boolean): FlowStateMachineImpl<*>? { private fun Checkpoint.getFiberFromCheckpoint(runId: StateMachineRunId, firstRestore: Boolean): FlowStateMachineImpl<*>? {
try { try {
return when(flowState) { return when(flowState) {

View File

@ -63,7 +63,6 @@ internal class FlowDefaultUncaughtExceptionHandler(
scheduledExecutor.schedule({ setFlowToHospitalizedRescheduleOnFailure(id) }, 0, TimeUnit.SECONDS) scheduledExecutor.schedule({ setFlowToHospitalizedRescheduleOnFailure(id) }, 0, TimeUnit.SECONDS)
} }
@Suppress("TooGenericExceptionCaught")
private fun setFlowToHospitalizedRescheduleOnFailure(id: StateMachineRunId) { private fun setFlowToHospitalizedRescheduleOnFailure(id: StateMachineRunId) {
try { try {
innerState.withLock { innerState.withLock {

View File

@ -182,7 +182,7 @@ internal class SingleThreadedStateMachineManager(
) )
val (flows, pausedFlows) = restoreFlowsFromCheckpoints() val (flows, pausedFlows) = restoreFlowsFromCheckpoints()
metrics.register("Flows.InFlight", Gauge<Int> { innerState.flows.size }) metrics.register("Flows.InFlight", Gauge { innerState.flows.size })
setFlowDefaultUncaughtExceptionHandler() setFlowDefaultUncaughtExceptionHandler()
@ -633,7 +633,7 @@ internal class SingleThreadedStateMachineManager(
} }
} }
@Suppress("TooGenericExceptionCaught", "ComplexMethod", "MaxLineLength") // this is fully intentional here, see comment in the catch clause @Suppress("ComplexMethod", "MaxLineLength") // this is fully intentional here, see comment in the catch clause
override fun retryFlowFromSafePoint(currentState: StateMachineState) { override fun retryFlowFromSafePoint(currentState: StateMachineState) {
currentState.cancelFutureIfRunning() currentState.cancelFutureIfRunning()
// Get set of external events // Get set of external events
@ -973,7 +973,7 @@ internal class SingleThreadedStateMachineManager(
} }
totalStartedFlows.inc() totalStartedFlows.inc()
addAndStartFlow(flowId, flow) addAndStartFlow(flowId, flow)
return startedFuture.map { flow.fiber as FlowStateMachine<A> } return startedFuture.map { flow.fiber }
} }
override fun scheduleFlowTimeout(flowId: StateMachineRunId) { override fun scheduleFlowTimeout(flowId: StateMachineRunId) {
@ -1228,7 +1228,7 @@ internal class SingleThreadedStateMachineManager(
override val logic: Nothing? = null override val logic: Nothing? = null
override val id: StateMachineRunId = id override val id: StateMachineRunId = id
override val resultFuture: CordaFuture<Any?> = resultFuture override val resultFuture: CordaFuture<Any?> = resultFuture
override val clientId: String? = clientId override val clientId: String = clientId
} }
) )

View File

@ -131,7 +131,6 @@ class StartedFlowTransition(
} }
} }
@Suppress("TooGenericExceptionCaught")
private fun sendAndReceiveTransition(flowIORequest: FlowIORequest.SendAndReceive): TransitionResult { private fun sendAndReceiveTransition(flowIORequest: FlowIORequest.SendAndReceive): TransitionResult {
val sessionIdToMessage = LinkedHashMap<SessionId, SerializedBytes<Any>>() val sessionIdToMessage = LinkedHashMap<SessionId, SerializedBytes<Any>>()
val sessionIdToSession = LinkedHashMap<SessionId, FlowSessionImpl>() val sessionIdToSession = LinkedHashMap<SessionId, FlowSessionImpl>()
@ -195,7 +194,6 @@ class StartedFlowTransition(
} }
} }
@Suppress("TooGenericExceptionCaught")
private fun receiveTransition(flowIORequest: FlowIORequest.Receive): TransitionResult { private fun receiveTransition(flowIORequest: FlowIORequest.Receive): TransitionResult {
return builder { return builder {
val sessionIdToSession = LinkedHashMap<SessionId, FlowSessionImpl>() val sessionIdToSession = LinkedHashMap<SessionId, FlowSessionImpl>()
@ -279,9 +277,7 @@ class StartedFlowTransition(
var index = 0 var index = 0
for (sourceSessionId in sessionIdToSession.keys) { for (sourceSessionId in sessionIdToSession.keys) {
val sessionState = checkpoint.checkpointState.sessions[sourceSessionId] val sessionState = checkpoint.checkpointState.sessions[sourceSessionId]
if (sessionState == null) { ?: return freshErrorTransition(CannotFindSessionException(sourceSessionId))
return freshErrorTransition(CannotFindSessionException(sourceSessionId))
}
if (sessionState !is SessionState.Uninitiated) { if (sessionState !is SessionState.Uninitiated) {
continue continue
} }

View File

@ -42,7 +42,7 @@ class TopLevelTransition(
val log = contextLogger() val log = contextLogger()
} }
@Suppress("ComplexMethod", "TooGenericExceptionCaught") @Suppress("ComplexMethod")
override fun transition(): TransitionResult { override fun transition(): TransitionResult {
return try { return try {
if (startingState.isKilled) { if (startingState.isKilled) {

View File

@ -47,7 +47,6 @@ import kotlin.io.path.createDirectories
/** /**
* Handle to the node's external verifier. The verifier process is started lazily on the first verification request. * Handle to the node's external verifier. The verifier process is started lazily on the first verification request.
*/ */
@Suppress("TooGenericExceptionCaught")
class ExternalVerifierHandle(private val serviceHub: ServiceHubInternal) : AutoCloseable { class ExternalVerifierHandle(private val serviceHub: ServiceHubInternal) : AutoCloseable {
companion object { companion object {
private val log = contextLogger() private val log = contextLogger()

View File

@ -21,7 +21,6 @@ class JPANotaryService(
?: throw IllegalArgumentException("Failed to register ${this::class.java}: notary configuration not present") ?: throw IllegalArgumentException("Failed to register ${this::class.java}: notary configuration not present")
@Suppress("TooGenericExceptionCaught")
override val uniquenessProvider = with(services) { override val uniquenessProvider = with(services) {
val jpaNotaryConfig = try { val jpaNotaryConfig = try {
notaryConfig.extraConfig?.parseAs() ?: JPANotaryConfiguration() notaryConfig.extraConfig?.parseAs() ?: JPANotaryConfiguration()

View File

@ -229,8 +229,7 @@ class JPAUniquenessProvider(
var exceptionCaught: SQLException? = null var exceptionCaught: SQLException? = null
while (retryCount <= config.maxDBTransactionRetryCount) { while (retryCount <= config.maxDBTransactionRetryCount) {
try { try {
val res = block() return block()
return res
} catch (e: SQLException) { } catch (e: SQLException) {
retryCount++ retryCount++
Thread.sleep(backOff) Thread.sleep(backOff)
@ -242,7 +241,7 @@ class JPAUniquenessProvider(
} }
private fun findAllConflicts(session: Session, requests: List<CommitRequest>): MutableMap<StateRef, StateConsumptionDetails> { private fun findAllConflicts(session: Session, requests: List<CommitRequest>): MutableMap<StateRef, StateConsumptionDetails> {
log.info("Processing notarization requests with ${requests.sumBy { it.states.size }} input states and ${requests.sumBy { it.references.size }} references") log.info("Processing notarization requests with ${requests.sumOf { it.states.size }} input states and ${requests.sumOf { it.references.size }} references")
val allStates = requests.flatMap { it.states } val allStates = requests.flatMap { it.states }
val allReferences = requests.flatMap { it.references } val allReferences = requests.flatMap { it.references }
@ -338,7 +337,6 @@ class JPAUniquenessProvider(
return session.find(CommittedTransaction::class.java, txId.toString()) != null return session.find(CommittedTransaction::class.java, txId.toString()) != null
} }
@Suppress("TooGenericExceptionCaught")
private fun processRequests(requests: List<CommitRequest>) { private fun processRequests(requests: List<CommitRequest>) {
try { try {
// Note that there is an additional retry mechanism within the transaction itself. // Note that there is an additional retry mechanism within the transaction itself.

View File

@ -579,7 +579,6 @@ class FlowOperatorTests {
private val expectedPayload: String, private val expectedPayload: String,
private val future: CompletableFuture<Unit> private val future: CompletableFuture<Unit>
) : MessagingServiceSpy() { ) : MessagingServiceSpy() {
@Suppress("TooGenericExceptionCaught")
override fun send(message: Message, target: MessageRecipients, sequenceKey: Any) { override fun send(message: Message, target: MessageRecipients, sequenceKey: Any) {
try { try {
val sessionMessage = message.data.bytes.deserialize<InitialSessionMessage>() val sessionMessage = message.data.bytes.deserialize<InitialSessionMessage>()

View File

@ -36,25 +36,25 @@ object CreateStateFlow {
} }
fun errorTargetsToNum(vararg targets: ErrorTarget): Int { fun errorTargetsToNum(vararg targets: ErrorTarget): Int {
return targets.map { it.targetNumber }.sum() return targets.sumOf { it.targetNumber }
} }
private val targetMap = ErrorTarget.values().associateBy(ErrorTarget::targetNumber) private val targetMap = ErrorTarget.values().associateBy(ErrorTarget::targetNumber)
fun getServiceTarget(target: Int?): ErrorTarget { fun getServiceTarget(target: Int?): ErrorTarget {
return target?.let { targetMap.getValue(((it/10000) % 1000)*10000) } ?: CreateStateFlow.ErrorTarget.NoError return target?.let { targetMap.getValue(((it/10000) % 1000)*10000) } ?: ErrorTarget.NoError
} }
fun getServiceExceptionHandlingTarget(target: Int?): ErrorTarget { fun getServiceExceptionHandlingTarget(target: Int?): ErrorTarget {
return target?.let { targetMap.getValue(((it / 1000) % 10) * 1000) } ?: CreateStateFlow.ErrorTarget.NoError return target?.let { targetMap.getValue(((it / 1000) % 10) * 1000) } ?: ErrorTarget.NoError
} }
fun getTxTarget(target: Int?): ErrorTarget { fun getTxTarget(target: Int?): ErrorTarget {
return target?.let { targetMap.getValue(((it / 10) % 10) * 10) } ?: CreateStateFlow.ErrorTarget.NoError return target?.let { targetMap.getValue(((it / 10) % 10) * 10) } ?: ErrorTarget.NoError
} }
fun getFlowTarget(target: Int?): ErrorTarget { fun getFlowTarget(target: Int?): ErrorTarget {
return target?.let { targetMap.getValue(((it / 100) % 10) * 100) } ?: CreateStateFlow.ErrorTarget.NoError return target?.let { targetMap.getValue(((it / 100) % 10) * 100) } ?: ErrorTarget.NoError
} }
@InitiatingFlow @InitiatingFlow
@ -73,7 +73,7 @@ object CreateStateFlow {
val state = DbFailureContract.TestState( val state = DbFailureContract.TestState(
UniqueIdentifier(), UniqueIdentifier(),
listOf(ourIdentity), listOf(ourIdentity),
if (txTarget == CreateStateFlow.ErrorTarget.TxInvalidState) null else randomValue, if (txTarget == ErrorTarget.TxInvalidState) null else randomValue,
errorTarget, ourIdentity errorTarget, ourIdentity
) )
val txCommand = Command(DbFailureContract.Commands.Create(), ourIdentity.owningKey) val txCommand = Command(DbFailureContract.Commands.Create(), ourIdentity.owningKey)
@ -88,12 +88,11 @@ object CreateStateFlow {
val signedTx = serviceHub.signInitialTransaction(txBuilder) val signedTx = serviceHub.signInitialTransaction(txBuilder)
@Suppress("TooGenericExceptionCaught") // this is fully intentional here, to allow twiddling with exceptions according to config
try { try {
logger.info("Test flow: recording transaction") logger.info("Test flow: recording transaction")
serviceHub.recordTransactions(signedTx) serviceHub.recordTransactions(signedTx)
} catch (t: Throwable) { } catch (t: Throwable) {
if (getFlowTarget(errorTarget) == CreateStateFlow.ErrorTarget.FlowSwallowErrors) { if (getFlowTarget(errorTarget) == ErrorTarget.FlowSwallowErrors) {
logger.info("Test flow: Swallowing all exception! Muahahaha!", t) logger.info("Test flow: Swallowing all exception! Muahahaha!", t)
} else { } else {
logger.info("Test flow: caught exception - rethrowing") logger.info("Test flow: caught exception - rethrowing")

View File

@ -44,7 +44,6 @@ class DbListenerService(services: AppServiceHub) : SingletonSerializeAsToken() {
produced.forEach { produced.forEach {
val contractState = it.state.data as? DbFailureContract.TestState val contractState = it.state.data as? DbFailureContract.TestState
@Suppress("TooGenericExceptionCaught") // this is fully intentional here, to allow twiddling with exceptions
try { try {
when (CreateStateFlow.getServiceTarget(contractState?.errorTarget)) { when (CreateStateFlow.getServiceTarget(contractState?.errorTarget)) {
CreateStateFlow.ErrorTarget.ServiceSqlSyntaxError -> { CreateStateFlow.ErrorTarget.ServiceSqlSyntaxError -> {
@ -161,7 +160,7 @@ class DbListenerService(services: AppServiceHub) : SingletonSerializeAsToken() {
} }
if (onError != null) { if (onError != null) {
val onErrorWrapper: ((Throwable) -> Unit)? = { val onErrorWrapper: (Throwable) -> Unit = {
onErrorVisited?.let { onErrorVisited?.let {
it(services.myInfo.legalIdentities.first()) it(services.myInfo.legalIdentities.first())
} }

View File

@ -1,5 +1,5 @@
@file:JvmName("TestUtils") @file:JvmName("TestUtils")
@file:Suppress("TooGenericExceptionCaught", "MagicNumber", "ComplexMethod", "LongParameterList") @file:Suppress("MagicNumber", "ComplexMethod", "LongParameterList")
package net.corda.testing.core package net.corda.testing.core

View File

@ -53,7 +53,7 @@ import java.util.Optional
import kotlin.io.path.div import kotlin.io.path.div
import kotlin.io.path.listDirectoryEntries import kotlin.io.path.listDirectoryEntries
@Suppress("TooGenericExceptionCaught", "MagicNumber") @Suppress("MagicNumber")
class ExternalVerifier( class ExternalVerifier(
private val baseDirectory: Path, private val baseDirectory: Path,
private val fromNode: DataInputStream, private val fromNode: DataInputStream,

View File

@ -9,7 +9,6 @@ import java.nio.file.Path
import kotlin.io.path.div import kotlin.io.path.div
import kotlin.system.exitProcess import kotlin.system.exitProcess
@Suppress("TooGenericExceptionCaught")
object Main { object Main {
private val log = loggerFor<Main>() private val log = loggerFor<Main>()