From e2bcd0499e37922ceccda13f4268f0c0abc0ba8e Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Thu, 7 Dec 2023 13:30:26 +0000 Subject: [PATCH] ENT-11263: Remove TooGenericExceptionCaught detekt rule --- .../rpc/internal/RPCClientProxyHandler.kt | 2 - .../flows/FlowExternalAsyncOperationTest.kt | 1 - .../flows/FlowExternalOperationTest.kt | 1 - .../crypto/internal/PlatformSecureRandom.kt | 14 +- .../internal/concurrent/CordaFutureImpl.kt | 3 - .../telemetry/TelemetryServiceImpl.kt | 3 +- .../core/internal/verification/Verifier.kt | 1 - .../internal/ResilientSubscriber.kt | 2 - .../internal/AttachmentsClassLoader.kt | 36 ++-- .../ContractUpgradeTransactions.kt | 1 - .../net/corda/core/crypto/CryptoUtilsTest.kt | 6 +- detekt-baseline.xml | 173 ------------------ detekt-config.yml | 11 -- .../internal/bridging/AMQPBridgeManager.kt | 1 - .../bridging/BridgeControlListener.kt | 6 +- .../nodeapi/internal/crypto/X509Utilities.kt | 2 +- .../revocation/CertDistPointCrlSource.kt | 2 - .../revocation/CordaRevocationChecker.kt | 1 - .../StateMachineGeneralErrorHandlingTest.kt | 1 - .../net/corda/node/amqp/ProtonWrapperTests.kt | 1 - .../corda/node/flows/FlowEntityManagerTest.kt | 2 +- .../services/statemachine/FlowHospitalTest.kt | 9 +- .../net/corda/node/internal/AbstractNode.kt | 1 - .../net/corda/node/internal/NodeStartup.kt | 11 +- .../messaging/ArtemisMessagingServer.kt | 1 - .../persistence/HashedDistributionList.kt | 5 +- .../node/services/rpc/ArtemisRpcBroker.kt | 3 +- .../node/services/rpc/CheckpointDumperImpl.kt | 1 - .../statemachine/ActionExecutorImpl.kt | 2 - .../node/services/statemachine/FlowCreator.kt | 1 - .../FlowDefaultUncaughtExceptionHandler.kt | 1 - .../SingleThreadedStateMachineManager.kt | 8 +- .../transitions/StartedFlowTransition.kt | 6 +- .../transitions/TopLevelTransition.kt | 2 +- .../verification/ExternalVerifierHandle.kt | 1 - .../net/corda/notary/jpa/JPANotaryService.kt | 1 - .../corda/notary/jpa/JPAUniquenessProvider.kt | 6 +- .../statemachine/FlowOperatorTests.kt | 1 - .../r3/dbfailure/workflows/CreateStateFlow.kt | 15 +- .../dbfailure/workflows/DbListenerService.kt | 3 +- .../net/corda/testing/core/TestUtils.kt | 2 +- .../net/corda/verifier/ExternalVerifier.kt | 2 +- .../main/kotlin/net/corda/verifier/Main.kt | 1 - 43 files changed, 59 insertions(+), 294 deletions(-) diff --git a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt index 09ef600513..3cff1c3339 100644 --- a/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt +++ b/client/rpc/src/main/kotlin/net/corda/client/rpc/internal/RPCClientProxyHandler.kt @@ -150,7 +150,6 @@ internal class RPCClientProxyHandler( } } - @Suppress("TooGenericExceptionCaught") private fun closeObservable(observable: UnicastSubject>) { // Notify listeners of the observables that the connection is being terminated. try { @@ -589,7 +588,6 @@ internal class RPCClientProxyHandler( } if (observableIds != null) { log.debug { "Reaping ${observableIds.size} observables" } - @Suppress("TooGenericExceptionCaught") try { sendMessage(RPCApi.ClientToServer.ObservablesClosed(observableIds)) } catch(ex: Exception) { diff --git a/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalAsyncOperationTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalAsyncOperationTest.kt index b97121965c..2977decb47 100644 --- a/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalAsyncOperationTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalAsyncOperationTest.kt @@ -253,7 +253,6 @@ class FlowExternalAsyncOperationTest : AbstractFlowExternalOperationTest() { @StartableByRPC class FlowWithExternalAsyncOperationThatDirectlyAccessesServiceHubFailsRetry(party: Party) : FlowWithExternalProcess(party) { - @Suppress("TooGenericExceptionCaught") @Suspendable override fun testCode(): Any { return await(ExternalAsyncOperation(serviceHub) { _, _ -> diff --git a/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalOperationTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalOperationTest.kt index 7146f2c8ae..41e3515822 100644 --- a/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalOperationTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/flows/FlowExternalOperationTest.kt @@ -293,7 +293,6 @@ class FlowExternalOperationTest : AbstractFlowExternalOperationTest() { @StartableByRPC class FlowWithExternalOperationThatDirectlyAccessesServiceHubFailsRetry(party: Party) : FlowWithExternalProcess(party) { - @Suppress("TooGenericExceptionCaught") @Suspendable override fun testCode(): Any { try { diff --git a/core/src/main/kotlin/net/corda/core/crypto/internal/PlatformSecureRandom.kt b/core/src/main/kotlin/net/corda/core/crypto/internal/PlatformSecureRandom.kt index 9226a047bc..6e94948c3b 100644 --- a/core/src/main/kotlin/net/corda/core/crypto/internal/PlatformSecureRandom.kt +++ b/core/src/main/kotlin/net/corda/core/crypto/internal/PlatformSecureRandom.kt @@ -14,6 +14,7 @@ import java.io.InputStream import java.security.Provider import java.security.SecureRandom import java.security.SecureRandomSpi +import kotlin.system.exitProcess /** * This has been migrated into a separate class so that it @@ -29,23 +30,22 @@ val platformSecureRandom: () -> SecureRandom = when { } 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 { - const val algorithm = "CordaPRNG" + const val ALGORITHM = "CordaPRNG" + private val logger = loggerFor() } private val instance: SecureRandomSpi = if (SystemUtils.IS_OS_LINUX) tryAndUseLinuxSecureRandomSpi() else PlatformSecureRandomSpi() - @Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown") private fun tryAndUseLinuxSecureRandomSpi(): SecureRandomSpi = try { LinuxSecureRandomSpi() } catch (e: Exception) { logger.error("Unable to initialise LinuxSecureRandomSpi. The exception logged with this message might assist with diagnosis." + " The process will now exit.", e) - System.exit(1) - throw RuntimeException("Never reached, but calms the compiler.") + exitProcess(1) } override fun newInstance(constructorParameter: Any?) = instance @@ -63,7 +63,7 @@ private class PlatformSecureRandomSpi : SecureRandomSpi() { override fun engineGenerateSeed(numBytes: Int): ByteArray = secureRandom.generateSeed(numBytes) } -@Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown") +@Suppress("TooGenericExceptionThrown") private class LinuxSecureRandomSpi : SecureRandomSpi() { private fun openURandom(): InputStream { try { @@ -91,5 +91,5 @@ private class LinuxSecureRandomSpi : SecureRandomSpi() { // This is safe to share because of the underlying implementation of SecureRandomSpi private val sharedSecureRandom: SecureRandom by lazy(LazyThreadSafetyMode.PUBLICATION) { - SecureRandom.getInstance(PlatformSecureRandomService.algorithm) + SecureRandom.getInstance(PlatformSecureRandomService.ALGORITHM) } diff --git a/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt b/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt index 4dfa137212..92744ad2e6 100644 --- a/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt +++ b/core/src/main/kotlin/net/corda/core/internal/concurrent/CordaFutureImpl.kt @@ -84,7 +84,6 @@ fun CordaFuture.mapError(transform: (Throwable) -> Throwa * 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. */ -@Suppress("TooGenericExceptionCaught") fun CordaFuture.flatMap(transform: (V) -> CordaFuture): CordaFuture = CordaFutureImpl().also { result -> thenMatch(success@ { result.captureLater(try { @@ -146,7 +145,6 @@ interface ValueOrException { fun captureLater(f: CordaFuture) = f.then { capture { f.getOrThrow() } } /** Run the given block (in the foreground) and set this future to its outcome. */ - @Suppress("TooGenericExceptionCaught") fun capture(block: () -> V): Boolean { return set(try { block() @@ -174,7 +172,6 @@ class CordaFutureImpl(private val impl: CompletableFuture = CompletableFut override fun setException(t: Throwable) = impl.completeExceptionally(t) override fun then(callback: (CordaFuture) -> W) = thenImpl(defaultLog, callback) /** For testing only. */ - @Suppress("TooGenericExceptionCaught") fun thenImpl(log: Logger, callback: (CordaFuture) -> W) { impl.whenComplete { _, _ -> try { diff --git a/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt b/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt index 54bc1249f7..9c307cee00 100644 --- a/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt +++ b/core/src/main/kotlin/net/corda/core/internal/telemetry/TelemetryServiceImpl.kt @@ -178,7 +178,6 @@ class TelemetryServiceImpl : SingletonSerializeAsToken(), TelemetryService { } } - @Suppress("TooGenericExceptionCaught") inline fun span(name: String, attributes: Map = emptyMap(), flowLogic: FlowLogic<*>? = null, block: () -> R): R { val telemetryId = startSpan(name, attributes, flowLogic) try { @@ -195,7 +194,7 @@ class TelemetryServiceImpl : SingletonSerializeAsToken(), TelemetryService { } @CordaInternal - @Suppress("LongParameterList", "TooGenericExceptionCaught") + @Suppress("LongParameterList") inline fun spanForFlow(name: String, attributes: Map, flowLogic: FlowLogic<*>? = null, remoteSerializedTelemetry: SerializedTelemetry? = null, block: () -> R): R { val telemetryId = startSpanForFlow(name, attributes, flowLogic, remoteSerializedTelemetry) try { diff --git a/core/src/main/kotlin/net/corda/core/internal/verification/Verifier.kt b/core/src/main/kotlin/net/corda/core/internal/verification/Verifier.kt index f1e55acc80..5ca243260d 100644 --- a/core/src/main/kotlin/net/corda/core/internal/verification/Verifier.kt +++ b/core/src/main/kotlin/net/corda/core/internal/verification/Verifier.kt @@ -440,7 +440,6 @@ private class Validator(private val ltx: LedgerTransaction, private val transact * Verify the given [LedgerTransaction]. This includes validating * its contents, as well as executing all of its smart contracts. */ -@Suppress("TooGenericExceptionCaught") class TransactionVerifier(private val transactionClassLoader: ClassLoader) : Function, Unit> { // Loads the contract class from the transactionClassLoader. private fun createContractClass(id: SecureHash, contractClassName: ContractClassName): Class { diff --git a/core/src/main/kotlin/net/corda/core/observable/internal/ResilientSubscriber.kt b/core/src/main/kotlin/net/corda/core/observable/internal/ResilientSubscriber.kt index 074a17a719..05a9b24811 100644 --- a/core/src/main/kotlin/net/corda/core/observable/internal/ResilientSubscriber.kt +++ b/core/src/main/kotlin/net/corda/core/observable/internal/ResilientSubscriber.kt @@ -33,7 +33,6 @@ class ResilientSubscriber(actual: Subscriber) : SafeSubscriber(actua * It only delegates to [SafeSubscriber.onError] if it wraps an [ActionSubscriber] which is * a leaf in an Subscribers' tree structure. */ - @Suppress("TooGenericExceptionCaught") override fun onNext(t: T) { try { actual.onNext(t) @@ -62,7 +61,6 @@ class ResilientSubscriber(actual: Subscriber) : SafeSubscriber(actua /** * Duplicate of [SafeSubscriber._onError]. However, it will not call [Subscriber.unsubscribe]. */ - @Suppress("TooGenericExceptionCaught") override fun _onError(e: Throwable) { @Suppress("DEPRECATION") RxJavaPlugins.getInstance().errorHandler.handleError(e) diff --git a/core/src/main/kotlin/net/corda/core/serialization/internal/AttachmentsClassLoader.kt b/core/src/main/kotlin/net/corda/core/serialization/internal/AttachmentsClassLoader.kt index 9fb84cb85c..ad927efdf6 100644 --- a/core/src/main/kotlin/net/corda/core/serialization/internal/AttachmentsClassLoader.kt +++ b/core/src/main/kotlin/net/corda/core/serialization/internal/AttachmentsClassLoader.kt @@ -8,8 +8,8 @@ import net.corda.core.contracts.TransactionVerificationException import net.corda.core.contracts.TransactionVerificationException.OverlappingAttachmentsException import net.corda.core.contracts.TransactionVerificationException.PackageOwnershipException 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_1_2_CLASS_FILE_FORMAT_MAJOR_VERSION import net.corda.core.internal.JarSignatureCollector import net.corda.core.internal.NamedCacheFactory import net.corda.core.internal.PlatformVersionSwitches @@ -118,16 +118,11 @@ class AttachmentsClassLoader(attachments: List, // Reset the value to prevent Error due to a factory already defined factoryField.set(null, null) // Set our custom factory and wrap the current one into it - URL.setURLStreamHandlerFactory( - // Set the factory to a decorator - object : URLStreamHandlerFactory { - // route between our own and the pre-existing factory - override fun createURLStreamHandler(protocol: String): URLStreamHandler? { - return AttachmentURLStreamHandlerFactory.createURLStreamHandler(protocol) - ?: existingFactory.createURLStreamHandler(protocol) - } - } - ) + URL.setURLStreamHandlerFactory { protocol -> + // route between our own and the pre-existing factory + AttachmentURLStreamHandlerFactory.createURLStreamHandler(protocol) + ?: existingFactory.createURLStreamHandler(protocol) + } } } } @@ -158,9 +153,7 @@ class AttachmentsClassLoader(attachments: List, checkAttachments(attachments) } - private class AttachmentHashContext( - val txId: SecureHash, - val buffer: ByteArray = ByteArray(DEFAULT_BUFFER_SIZE)) + private class AttachmentHashContext(val buffer: ByteArray = ByteArray(DEFAULT_BUFFER_SIZE)) private fun hash(inputStream : InputStream, ctx : AttachmentHashContext) : SecureHash.SHA256 { val md = MessageDigest.getInstance(SecureHash.SHA2_256) @@ -189,7 +182,7 @@ class AttachmentsClassLoader(attachments: List, // This function attempts to strike a balance between security and usability when it comes to the no-overlap rule. // TODO - investigate potential exploits. private fun shouldCheckForNoOverlap(path: String, targetPlatformVersion: Int): Boolean { - require(path.toLowerCase() == path) + require(path.lowercase() == path) require(!path.contains('\\')) return when { @@ -234,7 +227,7 @@ class AttachmentsClassLoader(attachments: List, // claim their parts of the Java package namespace via registration with the zone operator. val classLoaderEntries = mutableMapOf() - val ctx = AttachmentHashContext(sampleTxId) + val ctx = AttachmentHashContext() for (attachment in attachments) { // We may have been given an attachment loaded from the database in which case, important info like // signers is already calculated. @@ -270,7 +263,7 @@ class AttachmentsClassLoader(attachments: List, // 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. - 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. if (path.endsWith(".class")) { @@ -285,7 +278,7 @@ class AttachmentsClassLoader(attachments: List, for ((namespace, pubkey) in params.packageOwnership) { // Note that due to the toLowerCase() call above, we'll be comparing against a lowercased // 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 if (pkgName == ns || pkgName.startsWith("$ns.")) { if (pubkey !in signers) @@ -358,7 +351,7 @@ object AttachmentsClassLoaderBuilder { val attachmentIds = attachments.mapTo(LinkedHashSet(), Attachment::id) 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 val transactionClassLoader = AttachmentsClassLoader(attachments, key.params, txId, isAttachmentTrusted, parent) val serializers = try { @@ -380,9 +373,9 @@ object AttachmentsClassLoaderBuilder { .withWhitelist(whitelistedClasses) .withCustomSerializers(serializers) .withoutCarpenter() - }) + } - val serializationContext = cachedSerializationContext.withProperties(mapOf( + val serializationContext = cachedSerializationContext.withProperties(mapOf( // Duplicate the SerializationContext from the cache and give // it these extra properties, just for this transaction. // 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() private val expiryQueue = ReferenceQueue() - @Suppress("TooGenericExceptionCaught") private fun purgeExpiryQueue() { // Close the AttachmentsClassLoader for every SerializationContext // that has already been garbage-collected. diff --git a/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt b/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt index f26ccd00ad..7ff7bc6e80 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/ContractUpgradeTransactions.kt @@ -290,7 +290,6 @@ private constructor( // upgraded attachments @CordaInternal @JvmSynthetic - @Suppress("TooGenericExceptionCaught") internal fun loadUpgradedContract(className: ContractClassName, id: SecureHash, classLoader: ClassLoader): UpgradedContract { return try { loadClassOfType>(className, false, classLoader) diff --git a/core/src/test/kotlin/net/corda/core/crypto/CryptoUtilsTest.kt b/core/src/test/kotlin/net/corda/core/crypto/CryptoUtilsTest.kt index 188a7fe2e2..b011d029c6 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/CryptoUtilsTest.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/CryptoUtilsTest.kt @@ -943,17 +943,17 @@ class CryptoUtilsTest { Security.removeProvider(CordaSecurityProvider.PROVIDER_NAME) // Try after removing CordaSecurityProvider. val secureRandomNotRegisteredCordaProvider = SecureRandom() - assertNotEquals(PlatformSecureRandomService.algorithm, secureRandomNotRegisteredCordaProvider.algorithm) + assertNotEquals(PlatformSecureRandomService.ALGORITHM, secureRandomNotRegisteredCordaProvider.algorithm) // Now register CordaSecurityProvider as last Provider. Security.addProvider(CordaSecurityProvider()) 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. Security.removeProvider(CordaSecurityProvider.PROVIDER_NAME) Security.insertProviderAt(CordaSecurityProvider(), 1) // This is base-1. val secureRandomRegisteredFirstCordaProvider = SecureRandom() - assertEquals(PlatformSecureRandomService.algorithm, secureRandomRegisteredFirstCordaProvider.algorithm) + assertEquals(PlatformSecureRandomService.ALGORITHM, secureRandomRegisteredFirstCordaProvider.algorithm) } } diff --git a/detekt-baseline.xml b/detekt-baseline.xml index 630c28d92d..01a15a1059 100644 --- a/detekt-baseline.xml +++ b/detekt-baseline.xml @@ -1393,179 +1393,6 @@ ThrowsCount:TransactionVerifierServiceInternal.kt$Verifier$ private fun getUniqueContractAttachmentsByContract(): Map<ContractClassName, ContractAttachment> 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 -> b // c -> b and a -> b // b -> a b -> 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 -> b a -> c // b -> c and c -> b // c -> a b -> a // and form a full cycle, meaning that the bi-directionality property is satisfied. private fun checkBidirectionalOutputEncumbrances(statesAndEncumbrance: List<Pair<Int, Int>>) ThrowsCount:WireTransaction.kt$WireTransaction.Companion$ @CordaInternal fun resolveStateRefBinaryComponent(stateRef: StateRef, services: ServicesForResolution): SerializedBytes<TransactionState<ContractState>>? - TooGenericExceptionCaught:AMQPChannelHandler.kt$AMQPChannelHandler$ex: Exception - TooGenericExceptionCaught:AMQPExceptions.kt$th: Throwable - TooGenericExceptionCaught:AMQPTestUtils.kt$e: Exception - TooGenericExceptionCaught:AbstractNode.kt$AbstractNode$e: Exception - TooGenericExceptionCaught:AbstractNode.kt$AbstractNode.<no name provided>$e: Exception - TooGenericExceptionCaught:AbstractNode.kt$ex: Exception - TooGenericExceptionCaught:AbstractNodeTests.kt$ColdJVM.Companion$t: Throwable - TooGenericExceptionCaught:Amount.kt$Amount.Companion$e: Exception - TooGenericExceptionCaught:ArtemisRpcBroker.kt$ArtemisRpcBroker$th: Throwable - TooGenericExceptionCaught:AttachmentDemo.kt$e: Exception - TooGenericExceptionCaught:AttachmentLoadingTests.kt$AttachmentLoadingTests.ConsumeAndBroadcastResponderFlow$e: Exception - TooGenericExceptionCaught:AttachmentVersionNumberMigration.kt$AttachmentVersionNumberMigration$e: Exception - TooGenericExceptionCaught:AzureSmbVolume.kt$AzureSmbVolume$e: Exception - TooGenericExceptionCaught:BCCryptoService.kt$BCCryptoService$e: Exception - TooGenericExceptionCaught:BankOfCordaWebApi.kt$BankOfCordaWebApi$e: Exception - TooGenericExceptionCaught:BlobInspector.kt$BlobInspector$e: Exception - TooGenericExceptionCaught:BootstrapperView.kt$BootstrapperView$e: Exception - TooGenericExceptionCaught:BrokerJaasLoginModule.kt$BrokerJaasLoginModule$e: Exception - TooGenericExceptionCaught:CertRole.kt$CertRole.Companion$ex: ArrayIndexOutOfBoundsException - TooGenericExceptionCaught:CheckpointAgent.kt$CheckpointAgent.Companion$e: Exception - TooGenericExceptionCaught:CheckpointAgent.kt$CheckpointHook$throwable: Throwable - TooGenericExceptionCaught:CheckpointDumperImpl.kt$CheckpointDumperImpl$e: Exception - TooGenericExceptionCaught:CheckpointVerifier.kt$CheckpointVerifier$e: Exception - TooGenericExceptionCaught:CollectSignaturesFlow.kt$SignTransactionFlow$e: Exception - TooGenericExceptionCaught:ConcurrencyUtils.kt$t: Throwable - TooGenericExceptionCaught:ConfigUtilities.kt$e:Exception - TooGenericExceptionCaught:ConnectionStateMachine.kt$ConnectionStateMachine$ex: Exception - TooGenericExceptionCaught:ContractAttachmentSerializer.kt$ContractAttachmentSerializer$e: Exception - TooGenericExceptionCaught:ContractUpgradeTransactions.kt$ContractUpgradeWireTransaction$e: Exception - TooGenericExceptionCaught:CordaAuthenticationPlugin.kt$CordaAuthenticationPlugin$e: Exception - TooGenericExceptionCaught:CordaClassResolver.kt$LoggingWhitelist.Companion$ioEx: Exception - TooGenericExceptionCaught:CordaPersistence.kt$CordaPersistence$e: Exception - TooGenericExceptionCaught:CordaRPCClientTest.kt$CordaRPCClientTest$e: Exception - TooGenericExceptionCaught:CordaRPCOpsImpl.kt$CordaRPCOpsImpl$e: Exception - TooGenericExceptionCaught:CordaServiceLifecycleFatalTests.kt$CordaServiceLifecycleFatalTests$ex: Exception - TooGenericExceptionCaught:CryptoUtilsTest.kt$CryptoUtilsTest$e: Exception - TooGenericExceptionCaught:DBNetworkParametersStorage.kt$DBNetworkParametersStorage$e: Exception - TooGenericExceptionCaught:DataUploadServlet.kt$DataUploadServlet$e: RuntimeException - TooGenericExceptionCaught:DbMapDeadlockTest.kt$DbMapDeadlockTest$e: Exception - TooGenericExceptionCaught:DemoBenchView.kt$DemoBenchView$e: Exception - TooGenericExceptionCaught:DeserializationInput.kt$DeserializationInput$e: Exception - TooGenericExceptionCaught:DeserializeSimpleTypesTests.kt$DeserializeSimpleTypesTests$e: Exception - TooGenericExceptionCaught:DistributionMux.kt$DistributionMux$ex: Exception - TooGenericExceptionCaught:DockerInstantiator.kt$DockerInstantiator$e: Exception - TooGenericExceptionCaught:DriverDSLImpl.kt$DriverDSLImpl$e: Exception - TooGenericExceptionCaught:DriverDSLImpl.kt$DriverDSLImpl.Companion$th: Throwable - TooGenericExceptionCaught:DriverDSLImpl.kt$exception: Throwable - TooGenericExceptionCaught:DriverTests.kt$DriverTests$e: Exception - TooGenericExceptionCaught:ErrorHandling.kt$ErrorHandling.CheckpointAfterErrorFlow$t: Throwable - TooGenericExceptionCaught:EventProcessor.kt$EventProcessor$ex: Exception - TooGenericExceptionCaught:Eventually.kt$e: Exception - TooGenericExceptionCaught:Expect.kt$exception: Exception - TooGenericExceptionCaught:Explorer.kt$Explorer$e: Exception - TooGenericExceptionCaught:FinanceJSONSupport.kt$CalendarDeserializer$e: Exception - TooGenericExceptionCaught:FlowHandle.kt$FlowProgressHandleImpl$e: Exception - TooGenericExceptionCaught:FlowMessaging.kt$FlowMessagingImpl$exception: Exception - TooGenericExceptionCaught:FlowStackSnapshotTest.kt$FlowStackSnapshotTest$exception: Exception - TooGenericExceptionCaught:FlowStateMachineImpl.kt$FlowStateMachineImpl$exception: Exception - TooGenericExceptionCaught:FlowStateMachineImpl.kt$FlowStateMachineImpl$t: Throwable - TooGenericExceptionCaught:FutureMatchers.kt$<no name provided>$e: Exception - TooGenericExceptionCaught:HibernateConfiguration.kt$HibernateConfiguration$e: Exception - TooGenericExceptionCaught:HibernateQueryCriteriaParser.kt$HibernateQueryCriteriaParser$e: Exception - TooGenericExceptionCaught:IRSDemo.kt$e: Exception - TooGenericExceptionCaught:IRSDemoTest.kt$IRSDemoTest.InterestRateSwapStateDeserializer$e: Exception - TooGenericExceptionCaught:InitialRegistrationCli.kt$InitialRegistration$e: Exception - TooGenericExceptionCaught:InitialRegistrationCli.kt$InitialRegistration.Companion$e: Exception - TooGenericExceptionCaught:Injectors.kt$e: Exception - TooGenericExceptionCaught:InstallShellExtensionsParser.kt$ShellExtensionsGenerator$exception: Exception - TooGenericExceptionCaught:InteractiveShell.kt$InteractiveShell$e: Exception - TooGenericExceptionCaught:InteractiveShell.kt$InteractiveShell$e: IndexOutOfBoundsException - TooGenericExceptionCaught:InterestSwapRestAPI.kt$InterestRateSwapAPI$ex: Exception - TooGenericExceptionCaught:InternalMockNetwork.kt$InternalMockNetwork$t: Throwable - TooGenericExceptionCaught:InternalTestUtils.kt$<no name provided>$e: Exception - TooGenericExceptionCaught:InternalUtils.kt$ex: Exception - TooGenericExceptionCaught:InternalUtils.kt$th: Throwable - TooGenericExceptionCaught:IssueCash.kt$IssueCash$e: Exception - TooGenericExceptionCaught:JacksonSupport.kt$JacksonSupport.PartyDeserializer$e: Exception - TooGenericExceptionCaught:JacksonSupport.kt$JacksonSupport.PublicKeyDeserializer$e: Exception - TooGenericExceptionCaught:JacksonSupport.kt$JacksonSupport.SecureHashDeserializer$e: Exception - TooGenericExceptionCaught:JarScanningCordappLoader.kt$JarScanningCordappLoader$e: Exception - TooGenericExceptionCaught:Kryo.kt$ImmutableClassSerializer$e: Exception - TooGenericExceptionCaught:LedgerDSLInterpreter.kt$Verifies$exception: Exception - TooGenericExceptionCaught:LoadTest.kt$LoadTest$throwable: Throwable - TooGenericExceptionCaught:LoginView.kt$LoginView$e: Exception - TooGenericExceptionCaught:Main.kt$Main$e: Exception - TooGenericExceptionCaught:MerkleTransaction.kt$FilteredTransaction$e: Exception - TooGenericExceptionCaught:MigrationServicesForResolution.kt$MigrationServicesForResolution$e: Exception - TooGenericExceptionCaught:MockAttachmentStorage.kt$MockAttachmentStorage$e: Exception - TooGenericExceptionCaught:MockCryptoService.kt$MockCryptoService$e: Exception - TooGenericExceptionCaught:MockNodeMessagingService.kt$MockNodeMessagingService$e: Exception - TooGenericExceptionCaught:MultiRPCClient.kt$MultiRPCClient$ex: Throwable - TooGenericExceptionCaught:MyCustomNotaryService.kt$MyValidatingNotaryFlow$e: Exception - TooGenericExceptionCaught:NamedCacheTest.kt$NamedCacheTest$e: Exception - TooGenericExceptionCaught:NettyTestHandler.kt$NettyTestHandler$e: Throwable - TooGenericExceptionCaught:NetworkBootstrapper.kt$NetworkBootstrapper$e: Exception - TooGenericExceptionCaught:NetworkMapServer.kt$NetworkMapServer.InMemoryNetworkMapService$e: Exception - TooGenericExceptionCaught:NetworkMapUpdater.kt$NetworkMapUpdater$e: Exception - TooGenericExceptionCaught:NetworkMapUpdater.kt$NetworkMapUpdater.<no name provided>$e: Exception - TooGenericExceptionCaught:NetworkParameterOverridesSpec.kt$NetworkParameterOverridesSpec.PackageOwnershipSpec$e: Exception - TooGenericExceptionCaught:NetworkParametersReader.kt$NetworkParametersReader$e: Exception - TooGenericExceptionCaught:NetworkRegistrationHelper.kt$NetworkRegistrationHelper$e: Exception - TooGenericExceptionCaught:NodeController.kt$NodeController$e: Exception - TooGenericExceptionCaught:NodeInfoWatcher.kt$NodeInfoWatcher$e: Exception - TooGenericExceptionCaught:NodeInterestRates.kt$NodeInterestRates$e: Exception - TooGenericExceptionCaught:NodeMonitorModel.kt$NodeMonitorModel$e: Exception - TooGenericExceptionCaught:NodeProcess.kt$NodeProcess.Factory$e: Exception - TooGenericExceptionCaught:NodeRPC.kt$NodeRPC$e: Exception - TooGenericExceptionCaught:NodeRPC.kt$NodeRPC.<no name provided>$e: Exception - TooGenericExceptionCaught:NodeSchedulerService.kt$NodeSchedulerService$e: Exception - TooGenericExceptionCaught:NodeStartup.kt$NodeStartup$e: Exception - TooGenericExceptionCaught:NodeTerminalView.kt$NodeTerminalView$e: Exception - TooGenericExceptionCaught:NodeVaultService.kt$NodeVaultService$e: Exception - TooGenericExceptionCaught:NodeVaultServiceTest.kt$NodeVaultServiceTest$e: Exception - TooGenericExceptionCaught:NonValidatingNotaryFlow.kt$NonValidatingNotaryFlow$e: Exception - TooGenericExceptionCaught:NotaryServiceFlow.kt$NotaryServiceFlow$e: Exception - TooGenericExceptionCaught:NotaryUtils.kt$e: Exception - TooGenericExceptionCaught:ObjectDiffer.kt$ObjectDiffer$throwable: Exception - TooGenericExceptionCaught:P2PMessagingClient.kt$P2PMessagingClient$e: Exception - TooGenericExceptionCaught:PersistentUniquenessProvider.kt$PersistentUniquenessProvider$e: Exception - TooGenericExceptionCaught:ProfileController.kt$ProfileController$e: Exception - TooGenericExceptionCaught:PropertyValidationTest.kt$PropertyValidationTest$e: Exception - TooGenericExceptionCaught:QuasarInstrumentationHook.kt$QuasarInstrumentationHook$throwable: Throwable - TooGenericExceptionCaught:R3Pty.kt$R3Pty$e: Exception - TooGenericExceptionCaught:RPCApi.kt$RPCApi.ServerToClient.Companion$e: Exception - TooGenericExceptionCaught:RPCClient.kt$RPCClient$throwable: Throwable - TooGenericExceptionCaught:RPCClientProxyHandler.kt$RPCClientProxyHandler$e: Exception - TooGenericExceptionCaught:RPCClientProxyHandler.kt$RPCClientProxyHandler$e: RuntimeException - TooGenericExceptionCaught:RPCPermissionResolver.kt$RPCPermissionResolver.InterfaceMethodMapCacheLoader$ex: Exception - TooGenericExceptionCaught:RPCServer.kt$RPCServer$e: Exception - TooGenericExceptionCaught:RPCServer.kt$RPCServer$exception: Throwable - TooGenericExceptionCaught:RPCServer.kt$RPCServer$throwable: Throwable - TooGenericExceptionCaught:RPCStabilityTests.kt$RPCStabilityTests$e2: Exception - TooGenericExceptionCaught:RPCStabilityTests.kt$RPCStabilityTests$e: Exception - TooGenericExceptionCaught:RandomFailingProxy.kt$RandomFailingProxy$e: Exception - TooGenericExceptionCaught:ReceiveTransactionFlow.kt$ReceiveTransactionFlow$e: Exception - TooGenericExceptionCaught:ReconnectingCordaRPCOps.kt$ReconnectingCordaRPCOps.ReconnectingRPCConnection$ex: Exception - TooGenericExceptionCaught:ReconnectingObservable.kt$ReconnectingObservable.ReconnectingSubscriber$e: Exception - TooGenericExceptionCaught:RpcServerObservableSerializerTests.kt$RpcServerObservableSerializerTests$e: Exception - TooGenericExceptionCaught:SSLHelper.kt$ex: Exception - TooGenericExceptionCaught:SerializationOutputTests.kt$SerializationOutputTests$t: Throwable - TooGenericExceptionCaught:ShutdownManager.kt$ShutdownManager$t: Throwable - TooGenericExceptionCaught:SimpleAMQPClient.kt$SimpleAMQPClient$e: Exception - TooGenericExceptionCaught:SimpleMQClient.kt$SimpleMQClient$e: Exception - TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$e: Exception - TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$ex: Exception - TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$exception: Exception - TooGenericExceptionCaught:SingleThreadedStateMachineManager.kt$SingleThreadedStateMachineManager$t: Throwable - TooGenericExceptionCaught:StandaloneShell.kt$StandaloneShell$e: Exception - TooGenericExceptionCaught:StandardConfigValueParsers.kt$e: Exception - TooGenericExceptionCaught:StringToMethodCallParser.kt$StringToMethodCallParser$e: Exception - TooGenericExceptionCaught:TLSAuthenticationTests.kt$TLSAuthenticationTests$ex: Exception - TooGenericExceptionCaught:ThrowableSerializer.kt$ThrowableSerializer$e: Exception - TooGenericExceptionCaught:TlsDiffAlgorithmsTest.kt$TlsDiffAlgorithmsTest$ex: Exception - TooGenericExceptionCaught:TlsDiffProtocolsTest.kt$TlsDiffProtocolsTest$ex: Exception - TooGenericExceptionCaught:TraderDemo.kt$TraderDemo$e: Exception - TooGenericExceptionCaught:TransactionBuilder.kt$TransactionBuilder$e: Throwable - TooGenericExceptionCaught:TransactionSignatureTest.kt$TransactionSignatureTest$e: Throwable - TooGenericExceptionCaught:TransactionUtils.kt$e: Exception - TooGenericExceptionCaught:TransformTypes.kt$TransformTypes.Companion$e: IndexOutOfBoundsException - TooGenericExceptionCaught:TransitionExecutorImpl.kt$TransitionExecutorImpl$exception: Exception - TooGenericExceptionCaught:Try.kt$Try.Companion$t: Throwable - TooGenericExceptionCaught:UserValidationPlugin.kt$UserValidationPlugin$e: Throwable - TooGenericExceptionCaught:Utils.kt$e: Exception - TooGenericExceptionCaught:V1NodeConfigurationSpec.kt$V1NodeConfigurationSpec$e: Exception - TooGenericExceptionCaught:ValidatingNotaryFlow.kt$ValidatingNotaryFlow$e: Exception - TooGenericExceptionCaught:VaultStateMigration.kt$VaultStateIterator$e: Exception - TooGenericExceptionCaught:VaultStateMigration.kt$VaultStateMigration$e: Exception - TooGenericExceptionCaught:WebServer.kt$WebServer$e: Exception - TooGenericExceptionCaught:WebServer.kt$e: Exception - TooGenericExceptionCaught:WebServer.kt$ex: Exception - TooGenericExceptionCaught:WithMockNet.kt$WithMockNet.<no name provided>$e: Exception - TooGenericExceptionCaught:X509EdDSAEngine.kt$X509EdDSAEngine$e: Exception - TooGenericExceptionCaught:X509UtilitiesTest.kt$X509UtilitiesTest$ex: Exception TooGenericExceptionThrown:AMQPExceptionsTests.kt$AMQPExceptionsTests$throw Exception("FAILED") TooGenericExceptionThrown:AzureBackend.kt$AzureBackend.Companion$throw RuntimeException(e) TooGenericExceptionThrown:ClassLoadingUtilsTest.kt$ClassLoadingUtilsTest$throw RuntimeException() diff --git a/detekt-config.yml b/detekt-config.yml index 9aa08b9df7..2a0d80c65d 100644 --- a/detekt-config.yml +++ b/detekt-config.yml @@ -77,17 +77,6 @@ empty-blocks: exceptions: active: true excludes: "**/buildSrc/**" - TooGenericExceptionCaught: - active: true - exceptionNames: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - NullPointerException - - IndexOutOfBoundsException - - RuntimeException - - Throwable TooGenericExceptionThrown: active: true exceptionNames: diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt index 1560c87499..d95edef97f 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/AMQPBridgeManager.kt @@ -1,4 +1,3 @@ -@file:Suppress("TooGenericExceptionCaught") // needs to catch and handle/rethrow *all* exceptions in many places package net.corda.nodeapi.internal.bridging import co.paralleluniverse.fibers.instrument.DontInstrument diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt index 357088bc0a..84974450d4 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/bridging/BridgeControlListener.kt @@ -1,4 +1,3 @@ -@file:Suppress("TooGenericExceptionCaught") // needs to catch and handle/rethrow *all* exceptions package net.corda.nodeapi.internal.bridging import net.corda.core.identity.CordaX500Name @@ -27,6 +26,7 @@ import rx.Observable import rx.subjects.PublishSubject import java.time.Duration import java.util.* +import kotlin.system.exitProcess class BridgeControlListener(private val keyStore: CertificateStore, trustStore: CertificateStore, @@ -142,7 +142,7 @@ class BridgeControlListener(private val keyStore: CertificateStore, val notifyMessage = data.deserialize(context = SerializationDefaults.P2P_CONTEXT) if (notifyMessage.bridgeIdentity != bridgeId) { log.error("Fatal Error! Two bridges have been configured simultaneously! Check the enterpriseConfiguration.externalBridge status") - System.exit(1) + exitProcess(1) } } catch (ex: Exception) { log.error("Unable to process bridge notification message", ex) @@ -204,7 +204,7 @@ class BridgeControlListener(private val keyStore: CertificateStore, is BridgeControl.NodeToBridgeSnapshot -> { if (!isConfigured(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) }) { log.error("Invalid queue names in control message $controlMessage") diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/crypto/X509Utilities.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/crypto/X509Utilities.kt index 3fef43cf30..22c85cb332 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/crypto/X509Utilities.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/crypto/X509Utilities.kt @@ -1,4 +1,4 @@ -@file:Suppress("MagicNumber", "TooGenericExceptionCaught") +@file:Suppress("MagicNumber") package net.corda.nodeapi.internal.crypto diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CertDistPointCrlSource.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CertDistPointCrlSource.kt index ee589e73a9..94200603a0 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CertDistPointCrlSource.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CertDistPointCrlSource.kt @@ -5,7 +5,6 @@ import com.github.benmanes.caffeine.cache.LoadingCache import net.corda.core.internal.readFully import net.corda.core.utilities.contextLogger import net.corda.core.utilities.debug -import net.corda.core.utilities.contextLogger import net.corda.core.utilities.minutes import net.corda.core.utilities.seconds 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. */ -@Suppress("TooGenericExceptionCaught") class CertDistPointCrlSource(cacheSize: Long = DEFAULT_CACHE_SIZE, cacheExpiry: Duration = DEFAULT_CACHE_EXPIRY, private val connectTimeout: Duration = DEFAULT_CONNECT_TIMEOUT, diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CordaRevocationChecker.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CordaRevocationChecker.kt index 1e0a3ecf53..6d6be84fd8 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CordaRevocationChecker.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/revocation/CordaRevocationChecker.kt @@ -33,7 +33,6 @@ class CordaRevocationChecker(private val crlSource: CrlSource, checkApprovedCRLs(cert, getCRLs(cert)) } - @Suppress("TooGenericExceptionCaught") private fun getCRLs(cert: X509Certificate): Set { val crls = try { crlSource.fetch(cert) diff --git a/node/src/integration-test-slow/kotlin/net/corda/node/services/statemachine/StateMachineGeneralErrorHandlingTest.kt b/node/src/integration-test-slow/kotlin/net/corda/node/services/statemachine/StateMachineGeneralErrorHandlingTest.kt index 7623546d5e..dee5ab6bb9 100644 --- a/node/src/integration-test-slow/kotlin/net/corda/node/services/statemachine/StateMachineGeneralErrorHandlingTest.kt +++ b/node/src/integration-test-slow/kotlin/net/corda/node/services/statemachine/StateMachineGeneralErrorHandlingTest.kt @@ -705,7 +705,6 @@ class StateMachineGeneralErrorHandlingTest : StateMachineErrorHandlingTest() { * * On shutdown this flow will still terminate correctly and not prevent the node from shutting down. */ - @Suppress("TooGenericExceptionCaught") @Test(timeout = 300_000) fun `a dead flow can be shutdown`() { startDriver { diff --git a/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt b/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt index a093e2604d..36daa4f176 100644 --- a/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt +++ b/node/src/integration-test/kotlin/net/corda/node/amqp/ProtonWrapperTests.kt @@ -213,7 +213,6 @@ class ProtonWrapperTests { assertTrue(done) } - @Suppress("TooGenericExceptionCaught") // Too generic exception thrown! @Test(timeout=300_000) fun `AMPQClient that fails to handshake with a server will retry the server`() { /* diff --git a/node/src/integration-test/kotlin/net/corda/node/flows/FlowEntityManagerTest.kt b/node/src/integration-test/kotlin/net/corda/node/flows/FlowEntityManagerTest.kt index d24a563cb7..7d8c56633d 100644 --- a/node/src/integration-test/kotlin/net/corda/node/flows/FlowEntityManagerTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/flows/FlowEntityManagerTest.kt @@ -42,7 +42,7 @@ import java.util.concurrent.Semaphore import javax.persistence.PersistenceException import kotlin.test.assertEquals -@Suppress("TooGenericExceptionCaught", "TooGenericExceptionThrown") +@Suppress("TooGenericExceptionThrown") class FlowEntityManagerTest : AbstractFlowEntityManagerTest() { @Before diff --git a/node/src/integration-test/kotlin/net/corda/node/services/statemachine/FlowHospitalTest.kt b/node/src/integration-test/kotlin/net/corda/node/services/statemachine/FlowHospitalTest.kt index f14f60cc5b..91bda3c280 100644 --- a/node/src/integration-test/kotlin/net/corda/node/services/statemachine/FlowHospitalTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/services/statemachine/FlowHospitalTest.kt @@ -139,7 +139,7 @@ class FlowHospitalTest { @Test(timeout = 300_000) fun `HospitalizeFlowException thrown`() { - var observationCounter: Int = 0 + var observationCounter = 0 StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ -> ++observationCounter } @@ -161,7 +161,7 @@ class FlowHospitalTest { @Test(timeout = 300_000) fun `Custom exception wrapping HospitalizeFlowException thrown`() { - var observationCounter: Int = 0 + var observationCounter = 0 StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ -> ++observationCounter } @@ -183,7 +183,7 @@ class FlowHospitalTest { @Test(timeout = 300_000) fun `Custom exception extending HospitalizeFlowException thrown`() { - var observationCounter: Int = 0 + var observationCounter = 0 StaffedFlowHospital.onFlowKeptForOvernightObservation.add { _, _ -> ++observationCounter } @@ -470,7 +470,7 @@ class FlowHospitalTest { @Suspendable override fun call() { - val throwable = hospitalizeFlowExceptionClass.newInstance() + val throwable = hospitalizeFlowExceptionClass.getDeclaredConstructor().newInstance() (throwable as? Throwable)?.let { throw it } @@ -561,7 +561,6 @@ class FlowHospitalTest { var exceptionSeenInUserFlow = false } - @Suppress("TooGenericExceptionCaught") @Suspendable override fun call() { val consumeError = session.receive().unwrap { it } diff --git a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt index ece28a229f..2a96257823 100644 --- a/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/net/corda/node/internal/AbstractNode.kt @@ -1237,7 +1237,6 @@ abstract class AbstractNode(val configuration: NodeConfiguration, */ override fun jdbcSession(): Connection = RestrictedConnection(database.createSession(), services) - @Suppress("TooGenericExceptionCaught") override fun withEntityManager(block: EntityManager.() -> T): T { return database.transaction(useErrorHandler = false) { session.flush() diff --git a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt index 1772210e56..3008eeac07 100644 --- a/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt +++ b/node/src/main/kotlin/net/corda/node/internal/NodeStartup.kt @@ -51,7 +51,6 @@ import net.corda.node.services.config.shouldStartLocalShell import net.corda.node.utilities.registration.NodeRegistrationException import net.corda.nodeapi.internal.JVMAgentUtilities import net.corda.nodeapi.internal.addShutdownHook -import net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException import net.corda.nodeapi.internal.persistence.DatabaseIncompatibleException import org.fusesource.jansi.Ansi import org.slf4j.bridge.SLF4JBridgeHandler @@ -217,7 +216,7 @@ open class NodeStartup : NodeStartupLogging { if (requireCertificates && !canReadCertificatesDirectory(configuration.certificatesDirectory, configuration.devMode)) return ExitCodes.FAILURE // 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. if (attempt { preNetworkRegistration(configuration) }.doOnFailure(Consumer(::handleRegistrationError)) !is Try.Success) return ExitCodes.FAILURE @@ -472,7 +471,6 @@ interface NodeStartupLogging { companion object { val logger by lazy { contextLogger() } val startupErrors = setOf(MultipleCordappsForFlowException::class, CheckpointIncompatibleException::class, AddressBindingException::class, NetworkParametersReader::class, DatabaseIncompatibleException::class) - @Suppress("TooGenericExceptionCaught") val PRINT_ERRORS_TO_STD_ERR = try { System.getProperty("net.corda.node.printErrorsToStdErr") == "true" } catch (e: NullPointerException) { @@ -515,7 +513,6 @@ interface NodeStartupLogging { when { error is ErrorCode<*> -> logger.report(error) 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("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.") @@ -541,14 +538,14 @@ fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean { try { logPath.safeSymbolicRead().createDirectories() } 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 } 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 } 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 } diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt b/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt index c0a6ed0388..31e55e6b61 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/ArtemisMessagingServer.kt @@ -113,7 +113,6 @@ class ArtemisMessagingServer(private val config: NodeConfiguration, registerPostQueueDeletionCallback { address, qName -> log.debug { "Queue deleted: $qName for $address" } } } - @Suppress("TooGenericExceptionCaught") try { activeMQServer.startSynchronously() } catch (e: Throwable) { diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt b/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt index 5fee0f24b2..756f33a296 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/HashedDistributionList.kt @@ -10,7 +10,6 @@ import java.io.DataOutputStream import java.nio.ByteBuffer import java.time.Instant -@Suppress("TooGenericExceptionCaught") @CordaSerializable data class HashedDistributionList( val senderStatesToRecord: StatesToRecord, @@ -60,7 +59,7 @@ data class HashedDistributionList( fun unauthenticatedDeserialise(encryptedBytes: ByteArray, encryptionService: EncryptionService): PublicHeader { val additionalData = encryptionService.extractUnauthenticatedAdditionalData(encryptedBytes) requireNotNull(additionalData) { "Missing additional data field" } - return deserialise(additionalData!!) + return deserialise(additionalData) } fun deserialise(bytes: ByteArray): PublicHeader { @@ -91,7 +90,7 @@ data class HashedDistributionList( fun decrypt(encryptedBytes: ByteArray, encryptionService: EncryptionService): HashedDistributionList { val (plaintext, authenticatedAdditionalData) = encryptionService.decrypt(encryptedBytes) requireNotNull(authenticatedAdditionalData) { "Missing authenticated header" } - val publicHeader = PublicHeader.deserialise(authenticatedAdditionalData!!) + val publicHeader = PublicHeader.deserialise(authenticatedAdditionalData) val input = DataInputStream(plaintext.inputStream()) try { val senderStatesToRecord = statesToRecordValues[input.readByte().toInt()] diff --git a/node/src/main/kotlin/net/corda/node/services/rpc/ArtemisRpcBroker.kt b/node/src/main/kotlin/net/corda/node/services/rpc/ArtemisRpcBroker.kt index 6ae79d378e..cf9162e48e 100644 --- a/node/src/main/kotlin/net/corda/node/services/rpc/ArtemisRpcBroker.kt +++ b/node/src/main/kotlin/net/corda/node/services/rpc/ArtemisRpcBroker.kt @@ -52,7 +52,6 @@ class ArtemisRpcBroker internal constructor( } } - @Suppress("TooGenericExceptionCaught") override fun start() { logger.debug { "Artemis RPC broker is starting for: $addresses" } try { @@ -90,7 +89,7 @@ class ArtemisRpcBroker internal constructor( val serverSecurityManager = createArtemisSecurityManager(serverConfiguration.loginListener) 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" } } } } diff --git a/node/src/main/kotlin/net/corda/node/services/rpc/CheckpointDumperImpl.kt b/node/src/main/kotlin/net/corda/node/services/rpc/CheckpointDumperImpl.kt index f5802f09bb..1b68549dc0 100644 --- a/node/src/main/kotlin/net/corda/node/services/rpc/CheckpointDumperImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/rpc/CheckpointDumperImpl.kt @@ -107,7 +107,6 @@ class CheckpointDumperImpl(private val checkpointStorage: CheckpointStorage, pri context: CheckpointSerializationContext, runId: StateMachineRunId, flowState: FlowState.Started) { - @Suppress("TooGenericExceptionCaught") try { flowState.frozenFiber.checkpointDeserialize(context) } catch (e: Exception) { diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/ActionExecutorImpl.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/ActionExecutorImpl.kt index 87b4a508c5..9b3391cc43 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/ActionExecutorImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/ActionExecutorImpl.kt @@ -112,7 +112,6 @@ internal class ActionExecutorImpl( } } - @Suppress("TooGenericExceptionCaught") // this is fully intentional here, see comment in the catch clause @Suspendable private fun executeAcknowledgeMessages(action: Action.AcknowledgeMessages) { action.deduplicationHandlers.forEach { @@ -231,7 +230,6 @@ internal class ActionExecutorImpl( action.currentState.run { numberOfCommits = checkpoint.checkpointState.numberOfCommits } } - @Suppress("TooGenericExceptionCaught") @Suspendable private fun executeAsyncOperation(fiber: FlowFiber, action: Action.ExecuteAsyncOperation) { try { diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowCreator.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowCreator.kt index 504faa9995..ab0df0ea1e 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowCreator.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowCreator.kt @@ -174,7 +174,6 @@ class FlowCreator( return Flow(flowStateMachineImpl, resultFuture) } - @Suppress("TooGenericExceptionCaught") private fun Checkpoint.getFiberFromCheckpoint(runId: StateMachineRunId, firstRestore: Boolean): FlowStateMachineImpl<*>? { try { return when(flowState) { diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowDefaultUncaughtExceptionHandler.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowDefaultUncaughtExceptionHandler.kt index a77967258d..607d99ad76 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/FlowDefaultUncaughtExceptionHandler.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/FlowDefaultUncaughtExceptionHandler.kt @@ -63,7 +63,6 @@ internal class FlowDefaultUncaughtExceptionHandler( scheduledExecutor.schedule({ setFlowToHospitalizedRescheduleOnFailure(id) }, 0, TimeUnit.SECONDS) } - @Suppress("TooGenericExceptionCaught") private fun setFlowToHospitalizedRescheduleOnFailure(id: StateMachineRunId) { try { innerState.withLock { diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt index b971f7f7e2..2778173d86 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/SingleThreadedStateMachineManager.kt @@ -182,7 +182,7 @@ internal class SingleThreadedStateMachineManager( ) val (flows, pausedFlows) = restoreFlowsFromCheckpoints() - metrics.register("Flows.InFlight", Gauge { innerState.flows.size }) + metrics.register("Flows.InFlight", Gauge { innerState.flows.size }) 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) { currentState.cancelFutureIfRunning() // Get set of external events @@ -973,7 +973,7 @@ internal class SingleThreadedStateMachineManager( } totalStartedFlows.inc() addAndStartFlow(flowId, flow) - return startedFuture.map { flow.fiber as FlowStateMachine } + return startedFuture.map { flow.fiber } } override fun scheduleFlowTimeout(flowId: StateMachineRunId) { @@ -1228,7 +1228,7 @@ internal class SingleThreadedStateMachineManager( override val logic: Nothing? = null override val id: StateMachineRunId = id override val resultFuture: CordaFuture = resultFuture - override val clientId: String? = clientId + override val clientId: String = clientId } ) diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt index b0c2020802..fd3491376e 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/StartedFlowTransition.kt @@ -131,7 +131,6 @@ class StartedFlowTransition( } } - @Suppress("TooGenericExceptionCaught") private fun sendAndReceiveTransition(flowIORequest: FlowIORequest.SendAndReceive): TransitionResult { val sessionIdToMessage = LinkedHashMap>() val sessionIdToSession = LinkedHashMap() @@ -195,7 +194,6 @@ class StartedFlowTransition( } } - @Suppress("TooGenericExceptionCaught") private fun receiveTransition(flowIORequest: FlowIORequest.Receive): TransitionResult { return builder { val sessionIdToSession = LinkedHashMap() @@ -279,9 +277,7 @@ class StartedFlowTransition( var index = 0 for (sourceSessionId in sessionIdToSession.keys) { val sessionState = checkpoint.checkpointState.sessions[sourceSessionId] - if (sessionState == null) { - return freshErrorTransition(CannotFindSessionException(sourceSessionId)) - } + ?: return freshErrorTransition(CannotFindSessionException(sourceSessionId)) if (sessionState !is SessionState.Uninitiated) { continue } diff --git a/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/TopLevelTransition.kt b/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/TopLevelTransition.kt index 19de1970b7..513e09d3a0 100644 --- a/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/TopLevelTransition.kt +++ b/node/src/main/kotlin/net/corda/node/services/statemachine/transitions/TopLevelTransition.kt @@ -42,7 +42,7 @@ class TopLevelTransition( val log = contextLogger() } - @Suppress("ComplexMethod", "TooGenericExceptionCaught") + @Suppress("ComplexMethod") override fun transition(): TransitionResult { return try { if (startingState.isKilled) { diff --git a/node/src/main/kotlin/net/corda/node/verification/ExternalVerifierHandle.kt b/node/src/main/kotlin/net/corda/node/verification/ExternalVerifierHandle.kt index 4b82ab3cf1..e60cfbf510 100644 --- a/node/src/main/kotlin/net/corda/node/verification/ExternalVerifierHandle.kt +++ b/node/src/main/kotlin/net/corda/node/verification/ExternalVerifierHandle.kt @@ -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. */ -@Suppress("TooGenericExceptionCaught") class ExternalVerifierHandle(private val serviceHub: ServiceHubInternal) : AutoCloseable { companion object { private val log = contextLogger() diff --git a/node/src/main/kotlin/net/corda/notary/jpa/JPANotaryService.kt b/node/src/main/kotlin/net/corda/notary/jpa/JPANotaryService.kt index 6db10a8333..56dbba9cb6 100644 --- a/node/src/main/kotlin/net/corda/notary/jpa/JPANotaryService.kt +++ b/node/src/main/kotlin/net/corda/notary/jpa/JPANotaryService.kt @@ -21,7 +21,6 @@ class JPANotaryService( ?: throw IllegalArgumentException("Failed to register ${this::class.java}: notary configuration not present") - @Suppress("TooGenericExceptionCaught") override val uniquenessProvider = with(services) { val jpaNotaryConfig = try { notaryConfig.extraConfig?.parseAs() ?: JPANotaryConfiguration() diff --git a/node/src/main/kotlin/net/corda/notary/jpa/JPAUniquenessProvider.kt b/node/src/main/kotlin/net/corda/notary/jpa/JPAUniquenessProvider.kt index b678478da6..02638f1ab1 100644 --- a/node/src/main/kotlin/net/corda/notary/jpa/JPAUniquenessProvider.kt +++ b/node/src/main/kotlin/net/corda/notary/jpa/JPAUniquenessProvider.kt @@ -229,8 +229,7 @@ class JPAUniquenessProvider( var exceptionCaught: SQLException? = null while (retryCount <= config.maxDBTransactionRetryCount) { try { - val res = block() - return res + return block() } catch (e: SQLException) { retryCount++ Thread.sleep(backOff) @@ -242,7 +241,7 @@ class JPAUniquenessProvider( } private fun findAllConflicts(session: Session, requests: List): MutableMap { - 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 allReferences = requests.flatMap { it.references } @@ -338,7 +337,6 @@ class JPAUniquenessProvider( return session.find(CommittedTransaction::class.java, txId.toString()) != null } - @Suppress("TooGenericExceptionCaught") private fun processRequests(requests: List) { try { // Note that there is an additional retry mechanism within the transaction itself. diff --git a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowOperatorTests.kt b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowOperatorTests.kt index 7bea95fe4d..29d55aa2ce 100644 --- a/node/src/test/kotlin/net/corda/node/services/statemachine/FlowOperatorTests.kt +++ b/node/src/test/kotlin/net/corda/node/services/statemachine/FlowOperatorTests.kt @@ -579,7 +579,6 @@ class FlowOperatorTests { private val expectedPayload: String, private val future: CompletableFuture ) : MessagingServiceSpy() { - @Suppress("TooGenericExceptionCaught") override fun send(message: Message, target: MessageRecipients, sequenceKey: Any) { try { val sessionMessage = message.data.bytes.deserialize() diff --git a/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/CreateStateFlow.kt b/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/CreateStateFlow.kt index af1d9a20bd..eb02cc4a2c 100644 --- a/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/CreateStateFlow.kt +++ b/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/CreateStateFlow.kt @@ -36,25 +36,25 @@ object CreateStateFlow { } 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) 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 { - 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 { - 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 { - return target?.let { targetMap.getValue(((it / 100) % 10) * 100) } ?: CreateStateFlow.ErrorTarget.NoError + return target?.let { targetMap.getValue(((it / 100) % 10) * 100) } ?: ErrorTarget.NoError } @InitiatingFlow @@ -73,7 +73,7 @@ object CreateStateFlow { val state = DbFailureContract.TestState( UniqueIdentifier(), listOf(ourIdentity), - if (txTarget == CreateStateFlow.ErrorTarget.TxInvalidState) null else randomValue, + if (txTarget == ErrorTarget.TxInvalidState) null else randomValue, errorTarget, ourIdentity ) val txCommand = Command(DbFailureContract.Commands.Create(), ourIdentity.owningKey) @@ -88,12 +88,11 @@ object CreateStateFlow { val signedTx = serviceHub.signInitialTransaction(txBuilder) - @Suppress("TooGenericExceptionCaught") // this is fully intentional here, to allow twiddling with exceptions according to config try { logger.info("Test flow: recording transaction") serviceHub.recordTransactions(signedTx) } catch (t: Throwable) { - if (getFlowTarget(errorTarget) == CreateStateFlow.ErrorTarget.FlowSwallowErrors) { + if (getFlowTarget(errorTarget) == ErrorTarget.FlowSwallowErrors) { logger.info("Test flow: Swallowing all exception! Muahahaha!", t) } else { logger.info("Test flow: caught exception - rethrowing") diff --git a/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/DbListenerService.kt b/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/DbListenerService.kt index d28f9f9bd1..aa8ca2efcb 100644 --- a/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/DbListenerService.kt +++ b/testing/cordapps/dbfailure/dbfworkflows/src/main/kotlin/com/r3/dbfailure/workflows/DbListenerService.kt @@ -44,7 +44,6 @@ class DbListenerService(services: AppServiceHub) : SingletonSerializeAsToken() { produced.forEach { val contractState = it.state.data as? DbFailureContract.TestState - @Suppress("TooGenericExceptionCaught") // this is fully intentional here, to allow twiddling with exceptions try { when (CreateStateFlow.getServiceTarget(contractState?.errorTarget)) { CreateStateFlow.ErrorTarget.ServiceSqlSyntaxError -> { @@ -161,7 +160,7 @@ class DbListenerService(services: AppServiceHub) : SingletonSerializeAsToken() { } if (onError != null) { - val onErrorWrapper: ((Throwable) -> Unit)? = { + val onErrorWrapper: (Throwable) -> Unit = { onErrorVisited?.let { it(services.myInfo.legalIdentities.first()) } diff --git a/testing/core-test-utils/src/main/kotlin/net/corda/testing/core/TestUtils.kt b/testing/core-test-utils/src/main/kotlin/net/corda/testing/core/TestUtils.kt index 175f52f5ae..43e12ece4f 100644 --- a/testing/core-test-utils/src/main/kotlin/net/corda/testing/core/TestUtils.kt +++ b/testing/core-test-utils/src/main/kotlin/net/corda/testing/core/TestUtils.kt @@ -1,5 +1,5 @@ @file:JvmName("TestUtils") -@file:Suppress("TooGenericExceptionCaught", "MagicNumber", "ComplexMethod", "LongParameterList") +@file:Suppress("MagicNumber", "ComplexMethod", "LongParameterList") package net.corda.testing.core diff --git a/verifier/src/main/kotlin/net/corda/verifier/ExternalVerifier.kt b/verifier/src/main/kotlin/net/corda/verifier/ExternalVerifier.kt index fc1b5ec121..5b10672c38 100644 --- a/verifier/src/main/kotlin/net/corda/verifier/ExternalVerifier.kt +++ b/verifier/src/main/kotlin/net/corda/verifier/ExternalVerifier.kt @@ -53,7 +53,7 @@ import java.util.Optional import kotlin.io.path.div import kotlin.io.path.listDirectoryEntries -@Suppress("TooGenericExceptionCaught", "MagicNumber") +@Suppress("MagicNumber") class ExternalVerifier( private val baseDirectory: Path, private val fromNode: DataInputStream, diff --git a/verifier/src/main/kotlin/net/corda/verifier/Main.kt b/verifier/src/main/kotlin/net/corda/verifier/Main.kt index ba1269f63d..7507d01d5a 100644 --- a/verifier/src/main/kotlin/net/corda/verifier/Main.kt +++ b/verifier/src/main/kotlin/net/corda/verifier/Main.kt @@ -9,7 +9,6 @@ import java.nio.file.Path import kotlin.io.path.div import kotlin.system.exitProcess -@Suppress("TooGenericExceptionCaught") object Main { private val log = loggerFor
()