diff --git a/core/src/main/kotlin/net/corda/core/contracts/clauses/FirstComposition.kt b/core/src/main/kotlin/net/corda/core/contracts/clauses/FirstComposition.kt index 0f1e00a72b..2edea14625 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/clauses/FirstComposition.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/clauses/FirstComposition.kt @@ -4,18 +4,13 @@ import net.corda.core.contracts.AuthenticatedObject import net.corda.core.contracts.CommandData import net.corda.core.contracts.ContractState import net.corda.core.contracts.TransactionForContract -import net.corda.core.utilities.loggerFor import java.util.* /** * Compose a number of clauses, such that the first match is run, and it errors if none is run. */ @Deprecated("Use FirstOf instead") -class FirstComposition(val firstClause: Clause, vararg remainingClauses: Clause) : CompositeClause() { - companion object { - val logger = loggerFor>() - } - +class FirstComposition(firstClause: Clause, vararg remainingClauses: Clause) : CompositeClause() { override val clauses = ArrayList>() override fun matchedClauses(commands: List>): List> = listOf(clauses.first { it.matches(commands) }) diff --git a/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt b/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt index a1d354316b..0f9bbe129a 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/X509UtilitiesTest.kt @@ -59,7 +59,7 @@ class X509UtilitiesTest { serverCert.checkValidity(Date()) // throws on verification problems serverCert.verify(caCertAndKey.keyPair.public) // throws on verification problems assertFalse { serverCert.keyUsage[5] } // Bit 5 == keyCertSign according to ASN.1 spec (see full comment on KeyUsage property) - assertTrue { serverCert.basicConstraints === -1 } // This returns the signing path length should be -1 for non-CA certificate + assertTrue { serverCert.basicConstraints == -1 } // This returns the signing path length should be -1 for non-CA certificate assertEquals(2, serverCert.subjectAlternativeNames.size) var foundAliasDnsName = false for (entry in serverCert.subjectAlternativeNames) { @@ -224,7 +224,7 @@ class X509UtilitiesTest { var done = false var serverError = false - val serverThread = thread() { + val serverThread = thread { try { val sslServerSocket = serverSocket.accept() assert(sslServerSocket.isConnected) diff --git a/core/src/test/kotlin/net/corda/core/flows/TxKeyFlowUtilitiesTests.kt b/core/src/test/kotlin/net/corda/core/flows/TxKeyFlowUtilitiesTests.kt index a6e4b2f4f7..40c070f438 100644 --- a/core/src/test/kotlin/net/corda/core/flows/TxKeyFlowUtilitiesTests.kt +++ b/core/src/test/kotlin/net/corda/core/flows/TxKeyFlowUtilitiesTests.kt @@ -6,7 +6,6 @@ import net.corda.core.utilities.DUMMY_NOTARY import net.corda.testing.ALICE import net.corda.testing.BOB import net.corda.testing.MOCK_IDENTITY_SERVICE -import net.corda.testing.ledger import net.corda.testing.node.MockNetwork import org.junit.Before import org.junit.Test @@ -30,7 +29,6 @@ class TxKeyFlowUtilitiesTests { val notaryNode = net.createNotaryNode(null, DUMMY_NOTARY.name) val aliceNode = net.createPartyNode(notaryNode.info.address, ALICE.name) val bobNode = net.createPartyNode(notaryNode.info.address, BOB.name) - val aliceKey: Party = aliceNode.services.myInfo.legalIdentity val bobKey: Party = bobNode.services.myInfo.legalIdentity // Run the flows diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt index 09cea98ba2..99b1571c03 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt @@ -2,8 +2,6 @@ package net.corda.docs import net.corda.contracts.asset.Cash import net.corda.core.contracts.Amount -import net.corda.core.contracts.Issued -import net.corda.core.contracts.PartyAndReference import net.corda.core.contracts.USD import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.startFlow @@ -111,7 +109,6 @@ fun generateTransactions(proxy: CordaRPCOps) { val issueRef = OpaqueBytes.of(0) val notary = proxy.networkMapUpdates().first.first { it.advertisedServices.any { it.info.type.isNotary() } }.notaryIdentity val me = proxy.nodeIdentity().legalIdentity - val meAndRef = PartyAndReference(me, issueRef) while (true) { Thread.sleep(1000) val random = SplittableRandom() diff --git a/node/src/main/kotlin/net/corda/node/driver/Driver.kt b/node/src/main/kotlin/net/corda/node/driver/Driver.kt index 8afb1e93e2..b7e0857620 100644 --- a/node/src/main/kotlin/net/corda/node/driver/Driver.kt +++ b/node/src/main/kotlin/net/corda/node/driver/Driver.kt @@ -1,7 +1,6 @@ @file:JvmName("Driver") package net.corda.node.driver -import co.paralleluniverse.common.util.ProcessUtil import com.google.common.net.HostAndPort import com.google.common.util.concurrent.* import com.typesafe.config.Config @@ -59,7 +58,7 @@ private val log: Logger = loggerFor() */ interface DriverDSLExposedInterface { /** - * Starts a [Node] in a separate process. + * Starts a [net.corda.node.internal.Node] in a separate process. * * @param providedName Optional name of the node, which will be its legal name in [Party]. Defaults to something * random. Note that this must be unique as the driver uses it as a primary key! @@ -170,7 +169,6 @@ fun driver( isDebug: Boolean = false, driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()), portAllocation: PortAllocation = PortAllocation.Incremental(10000), - sshdPortAllocation: PortAllocation = PortAllocation.Incremental(20000), debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005), systemProperties: Map = emptyMap(), useTestClock: Boolean = false, @@ -179,7 +177,6 @@ fun driver( ) = genericDriver( driverDsl = DriverDSL( portAllocation = portAllocation, - sshdPortAllocation = sshdPortAllocation, debugPortAllocation = debugPortAllocation, systemProperties = systemProperties, driverDirectory = driverDirectory.toAbsolutePath(), @@ -336,7 +333,6 @@ class ShutdownManager(private val executorService: ExecutorService) { class DriverDSL( val portAllocation: PortAllocation, - val sshdPortAllocation: PortAllocation, val debugPortAllocation: PortAllocation, val systemProperties: Map, val driverDirectory: Path, @@ -526,7 +522,6 @@ class DriverDSL( override fun startNetworkMapService() { val debugPort = if (isDebug) debugPortAllocation.nextPort() else null val apiAddress = portAllocation.nextHostAndPort().toString() - val sshdAddress = sshdPortAllocation.nextHostAndPort().toString() val baseDirectory = driverDirectory / networkMapLegalName val config = ConfigHelper.loadConfig( baseDirectory = baseDirectory, diff --git a/node/src/main/kotlin/net/corda/node/services/api/AcceptsFileUpload.kt b/node/src/main/kotlin/net/corda/node/services/api/AcceptsFileUpload.kt index 10bcfb7e65..933e204dc1 100644 --- a/node/src/main/kotlin/net/corda/node/services/api/AcceptsFileUpload.kt +++ b/node/src/main/kotlin/net/corda/node/services/api/AcceptsFileUpload.kt @@ -1,8 +1,6 @@ package net.corda.node.services.api -import net.corda.core.crypto.SecureHash import net.corda.core.node.services.FileUploader -import java.io.InputStream /** * A service that implements AcceptsFileUpload can have new binary data provided to it via an HTTP upload. @@ -16,5 +14,5 @@ interface AcceptsFileUpload: FileUploader { /** What file extensions are acceptable for the file to be handed to upload() */ val acceptableFileExtensions: List - override fun accepts(prefix: String) = prefix == dataTypePrefix + override fun accepts(type: String) = type == dataTypePrefix } diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/StorageServiceImpl.kt b/node/src/main/kotlin/net/corda/node/services/persistence/StorageServiceImpl.kt index 6e41630fb0..0ad3623cf9 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/StorageServiceImpl.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/StorageServiceImpl.kt @@ -10,6 +10,7 @@ open class StorageServiceImpl(override val attachments: AttachmentStorage, lateinit override var uploaders: List fun initUploaders(uploadersList: List) { + @Suppress("DEPRECATION") uploaders = uploadersList } } diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt index 97caae2a8b..75f34f0722 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/irs/IRSDemoTest.kt @@ -3,7 +3,6 @@ package net.corda.irs import com.google.common.net.HostAndPort import com.google.common.util.concurrent.Futures import net.corda.client.rpc.CordaRPCClient -import net.corda.core.crypto.Party import net.corda.core.getOrThrow import net.corda.core.node.services.ServiceInfo import net.corda.irs.api.NodeInterestRates @@ -24,8 +23,8 @@ import java.time.LocalDate class IRSDemoTest : IntegrationTestCategory { val rpcUser = User("user", "password", emptySet()) - val currentDate = LocalDate.now() - val futureDate = currentDate.plusMonths(6) + val currentDate: LocalDate = LocalDate.now() + val futureDate: LocalDate = currentDate.plusMonths(6) @Test fun `runs IRS demo`() { @@ -45,7 +44,7 @@ class IRSDemoTest : IntegrationTestCategory { val nextFixingDates = getFixingDateObservable(nodeA.configuration) runUploadRates(controllerAddr) - runTrade(nodeAAddr, nodeA.nodeInfo.legalIdentity, nodeB.nodeInfo.legalIdentity) + runTrade(nodeAAddr) // Wait until the initial trade and all scheduled fixings up to the current date have finished nextFixingDates.first { it == null || it > currentDate } @@ -73,7 +72,7 @@ class IRSDemoTest : IntegrationTestCategory { assert(putJson(url, "\"$futureDate\"")) } - private fun runTrade(nodeAddr: HostAndPort, fixedRatePayer: Party, floatingRatePayer: Party) { + private fun runTrade(nodeAddr: HostAndPort) { val fileContents = IOUtils.toString(Thread.currentThread().contextClassLoader.getResourceAsStream("example-irs-trade.json"), Charsets.UTF_8.name()) val tradeFile = fileContents.replace("tradeXXX", "trade1") val url = URL("http://$nodeAddr/api/irs/deals") diff --git a/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt b/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt index 86658dc120..e53eb81c25 100644 --- a/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt +++ b/samples/irs-demo/src/main/kotlin/net/corda/irs/contract/IRS.kt @@ -21,12 +21,8 @@ val IRS_PROGRAM_ID = InterestRateSwap() // This is a placeholder for some types that we haven't identified exactly what they are just yet for things still in discussion @CordaSerializable -open class UnknownType() { - - override fun equals(other: Any?): Boolean { - return (other is UnknownType) - } - +open class UnknownType { + override fun equals(other: Any?): Boolean = other is UnknownType override fun hashCode() = 1 } @@ -188,7 +184,7 @@ class FloatingRatePaymentEvent(date: LocalDate, * Currently, we are not interested (excuse pun) in valuing the swap, calculating the PVs, DFs and all that good stuff (soon though). * This is just a representation of a vanilla Fixed vs Floating (same currency) IRS in the R3 prototype model. */ -class InterestRateSwap() : Contract { +class InterestRateSwap : Contract { override val legalContractReference = SecureHash.sha256("is_this_the_text_of_the_contract ? TBD") companion object { @@ -522,7 +518,7 @@ class InterestRateSwap() : Contract { class Group : GroupClauseVerifier, Commands, UniqueIdentifier>(AnyOf(Agree(), Fix(), Pay(), Mature())) { // Group by Trade ID for in / out states override fun groupStates(tx: TransactionForContract): List, UniqueIdentifier>> { - return tx.groupStates() { state -> state.linearId } + return tx.groupStates { state -> state.linearId } } } @@ -550,8 +546,8 @@ class InterestRateSwap() : Contract { val irs = outputs.filterIsInstance>().single() requireThat { "There are no in states for an agreement" by inputs.isEmpty() - "There are events in the fix schedule" by (irs.calculation.fixedLegPaymentSchedule.size > 0) - "There are events in the float schedule" by (irs.calculation.floatingLegPaymentSchedule.size > 0) + "There are events in the fix schedule" by (irs.calculation.fixedLegPaymentSchedule.isNotEmpty()) + "There are events in the float schedule" by (irs.calculation.floatingLegPaymentSchedule.isNotEmpty()) "All notionals must be non zero" by (irs.fixedLeg.notional.quantity > 0 && irs.floatingLeg.notional.quantity > 0) "The fixed leg rate must be positive" by (irs.fixedLeg.fixedRate.isPositive()) "The currency of the notionals must be the same" by (irs.fixedLeg.notional.token == irs.floatingLeg.notional.token) @@ -739,6 +735,7 @@ class InterestRateSwap() : Contract { fun toAnonymous(): State { return if (this.fixedLeg.fixedRatePayer is AnonymousParty) { + @Suppress("UNCHECKED_CAST") this as State } else { State(fixedLeg.toAnonymous(), floatingLeg.toAnonymous(), calculation, common, linearId) diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/identicon/IdenticonRenderer.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/identicon/IdenticonRenderer.kt index de92c8d2e6..d7162986d5 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/identicon/IdenticonRenderer.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/identicon/IdenticonRenderer.kt @@ -151,7 +151,7 @@ object IdenticonRenderer { private fun drawPatch(g: GraphicsContext, x: Double, y: Double, patchIndex: Int, turn: Int, patchSize: Double, _invert: Boolean, color: PatchColor) { val patch = patchTypes[patchIndex % patchTypes.size] - val invert = if ((patchFlags[patchIndex].toInt() and PATCH_INVERTED.toInt()) !== 0) !_invert else _invert + val invert = if ((patchFlags[patchIndex].toInt() and PATCH_INVERTED.toInt()) != 0) !_invert else _invert g.apply { // paint background clearRect(x, y, patchSize, patchSize) diff --git a/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt b/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt index d8383ebd83..38f4b00f1f 100644 --- a/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt +++ b/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierDriver.kt @@ -68,7 +68,6 @@ fun verifierDriver( isDebug: Boolean = false, driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()), portAllocation: PortAllocation = PortAllocation.Incremental(10000), - sshdPortAllocation: PortAllocation = PortAllocation.Incremental(20000), debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005), systemProperties: Map = emptyMap(), useTestClock: Boolean = false, @@ -78,7 +77,6 @@ fun verifierDriver( driverDsl = VerifierDriverDSL( DriverDSL( portAllocation = portAllocation, - sshdPortAllocation = sshdPortAllocation, debugPortAllocation = debugPortAllocation, systemProperties = systemProperties, driverDirectory = driverDirectory.toAbsolutePath(), @@ -260,10 +258,8 @@ data class VerifierDriverDSL( val locator = ActiveMQClient.createServerLocatorWithoutHA(transport) val sessionFactory = locator.createSessionFactory() val session = sessionFactory.createSession(NODE_USER, NODE_USER, false, true, true, locator.isPreAcknowledge, locator.ackBatchSize) - try { - return closure(session) - } finally { - session.close() + return session.use { + closure(it) } } diff --git a/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierTests.kt b/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierTests.kt index cf16d2a7f5..6bb9ab73fa 100644 --- a/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierTests.kt +++ b/verifier/src/integration-test/kotlin/net/corda/verifier/VerifierTests.kt @@ -76,7 +76,7 @@ class VerifierTests { val alice = aliceFuture.get() val verifier1 = startVerifier(alice) val verifier2 = startVerifier(alice) - val verifier3 = startVerifier(alice) + startVerifier(alice) alice.waitUntilNumberOfVerifiers(3) val remainingTransactionsCount = AtomicInteger(numberOfTransactions) val futures = transactions.map { transaction ->