diff --git a/.idea/compiler.xml b/.idea/compiler.xml index a2eed4b2f3..b98e8af1f4 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -37,6 +37,8 @@ + + @@ -177,6 +179,8 @@ + + @@ -200,6 +204,8 @@ + + diff --git a/core/build.gradle b/core/build.gradle index 6254a94599..673805bd2d 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -109,7 +109,8 @@ dependencies { // Apache JEXL: An embeddable expression evaluation library. // This may be temporary until we experiment with other ways to do on-the-fly contract specialisation via an API. compile "org.apache.commons:commons-jexl3:3.0" - compile 'commons-lang:commons-lang:2.6' + + compile "org.apache.commons:commons-lang3:3.9" // Java ed25519 implementation. See https://github.com/str4d/ed25519-java/ compile "net.i2p.crypto:eddsa:$eddsa_version" 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 1544707f6e..ec1900f4d8 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 @@ -4,7 +4,7 @@ package net.corda.core.crypto.internal import net.corda.core.DeleteForDJVM import net.corda.core.crypto.newSecureRandom -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import java.security.Provider import java.security.SecureRandom import java.security.SecureRandomSpi diff --git a/core/src/main/kotlin/net/corda/core/internal/StatePointerSearch.kt b/core/src/main/kotlin/net/corda/core/internal/StatePointerSearch.kt index 5e6c3f9baf..4fc21ca409 100644 --- a/core/src/main/kotlin/net/corda/core/internal/StatePointerSearch.kt +++ b/core/src/main/kotlin/net/corda/core/internal/StatePointerSearch.kt @@ -2,6 +2,7 @@ package net.corda.core.internal import net.corda.core.contracts.ContractState import net.corda.core.contracts.StatePointer +import org.apache.commons.lang3.reflect.FieldUtils import java.lang.reflect.Field import java.util.* @@ -25,20 +26,9 @@ class StatePointerSearch(val state: ContractState) { // Queue of fields to search. private val fieldQueue = ArrayDeque().apply { addAllFields(state) } - // Get fields of class and all super-classes. - private fun getAllFields(clazz: Class<*>): List { - val fields = mutableListOf() - var currentClazz = clazz - while (currentClazz.superclass != null) { - fields.addAll(currentClazz.declaredFields) - currentClazz = currentClazz.superclass - } - return fields - } - // Helper for adding all fields to the queue. private fun ArrayDeque.addAllFields(obj: Any) { - val fields = getAllFields(obj::class.java) + val fields = FieldUtils.getAllFieldsList(obj::class.java) val fieldsWithObjects = fields.mapNotNull { field -> // Ignore classes which have not been loaded. diff --git a/core/src/test/kotlin/net/corda/core/crypto/Base58Test.kt b/core/src/test/kotlin/net/corda/core/crypto/Base58Test.kt index 75ef3a8d09..52f6d481d7 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/Base58Test.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/Base58Test.kt @@ -1,6 +1,6 @@ package net.corda.core.crypto -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.junit.Test import java.math.BigInteger import java.util.* 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 5f03ea9894..c31d0e63ee 100644 --- a/core/src/test/kotlin/net/corda/core/crypto/CryptoUtilsTest.kt +++ b/core/src/test/kotlin/net/corda/core/crypto/CryptoUtilsTest.kt @@ -15,7 +15,7 @@ import net.i2p.crypto.eddsa.math.GroupElement import net.i2p.crypto.eddsa.spec.EdDSANamedCurveSpec import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable import net.i2p.crypto.eddsa.spec.EdDSAPublicKeySpec -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.bouncycastle.asn1.pkcs.PrivateKeyInfo import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo import org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey diff --git a/core/src/test/kotlin/net/corda/core/utilities/EncodingUtilsTest.kt b/core/src/test/kotlin/net/corda/core/utilities/EncodingUtilsTest.kt index 23c719fa24..1a9d7c694c 100644 --- a/core/src/test/kotlin/net/corda/core/utilities/EncodingUtilsTest.kt +++ b/core/src/test/kotlin/net/corda/core/utilities/EncodingUtilsTest.kt @@ -1,7 +1,7 @@ package net.corda.core.utilities import net.corda.core.crypto.AddressFormatException -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.junit.Test import kotlin.test.assertEquals import kotlin.test.fail diff --git a/node/src/main/kotlin/net/corda/node/internal/DBNetworkParametersStorage.kt b/node/src/main/kotlin/net/corda/node/internal/DBNetworkParametersStorage.kt index 9d067baeed..1d2b95d702 100644 --- a/node/src/main/kotlin/net/corda/node/internal/DBNetworkParametersStorage.kt +++ b/node/src/main/kotlin/net/corda/node/internal/DBNetworkParametersStorage.kt @@ -20,7 +20,7 @@ import net.corda.nodeapi.internal.network.verifiedNetworkMapCert import net.corda.nodeapi.internal.network.verifiedNetworkParametersCert import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX -import org.apache.commons.lang.ArrayUtils +import org.apache.commons.lang3.ArrayUtils import java.security.cert.X509Certificate import javax.persistence.* diff --git a/node/src/main/kotlin/net/corda/node/internal/Node.kt b/node/src/main/kotlin/net/corda/node/internal/Node.kt index 74520d6771..dac6a41ef0 100644 --- a/node/src/main/kotlin/net/corda/node/internal/Node.kt +++ b/node/src/main/kotlin/net/corda/node/internal/Node.kt @@ -62,7 +62,7 @@ import net.corda.nodeapi.internal.persistence.CouldNotCreateDataSourceException import net.corda.serialization.internal.* import net.corda.serialization.internal.amqp.SerializationFactoryCacheKey import net.corda.serialization.internal.amqp.SerializerFactory -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import org.h2.jdbc.JdbcSQLException import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -156,10 +156,9 @@ open class Node(configuration: NodeConfiguration, private fun hasMinimumJavaVersion(): Boolean { // when the ext.java8_minUpdateVersion gradle constant changes, so must this check - val major = SystemUtils.JAVA_VERSION_FLOAT return try { val update = getJavaUpdateVersion(SystemUtils.JAVA_VERSION) // To filter out cases like 1.8.0_202-ea - major == 1.8F && update >= 171 + SystemUtils.IS_JAVA_1_8 && update >= 171 } catch (e: NumberFormatException) { // custom JDKs may not have the update version (e.g. 1.8.0-adoptopenjdk) false } diff --git a/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt b/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt index 2fe6d1deb8..a8ed927ee3 100644 --- a/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt +++ b/node/src/main/kotlin/net/corda/node/services/identity/PersistentIdentityService.kt @@ -15,7 +15,7 @@ import net.corda.nodeapi.internal.crypto.X509CertificateFactory import net.corda.nodeapi.internal.crypto.x509Certificates import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import java.security.InvalidAlgorithmParameterException import java.security.PublicKey import java.security.cert.* diff --git a/node/src/main/kotlin/net/corda/node/services/keys/BasicHSMKeyManagementService.kt b/node/src/main/kotlin/net/corda/node/services/keys/BasicHSMKeyManagementService.kt index 97621bdf5a..1dc2cc3187 100644 --- a/node/src/main/kotlin/net/corda/node/services/keys/BasicHSMKeyManagementService.kt +++ b/node/src/main/kotlin/net/corda/node/services/keys/BasicHSMKeyManagementService.kt @@ -12,7 +12,7 @@ import net.corda.node.utilities.AppendOnlyPersistentMap import net.corda.nodeapi.internal.cryptoservice.CryptoService import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.bouncycastle.operator.ContentSigner import org.hibernate.annotations.Type import java.security.KeyPair diff --git a/node/src/main/kotlin/net/corda/node/services/keys/PersistentKeyManagementService.kt b/node/src/main/kotlin/net/corda/node/services/keys/PersistentKeyManagementService.kt index c35582f6a8..878a0243b2 100644 --- a/node/src/main/kotlin/net/corda/node/services/keys/PersistentKeyManagementService.kt +++ b/node/src/main/kotlin/net/corda/node/services/keys/PersistentKeyManagementService.kt @@ -9,7 +9,7 @@ import net.corda.node.services.identity.PersistentIdentityService import net.corda.node.utilities.AppendOnlyPersistentMap import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.bouncycastle.operator.ContentSigner import java.security.KeyPair import java.security.PrivateKey diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/DBCheckpointStorage.kt b/node/src/main/kotlin/net/corda/node/services/persistence/DBCheckpointStorage.kt index f58357abe0..d2f0d3163f 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/DBCheckpointStorage.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/DBCheckpointStorage.kt @@ -7,7 +7,7 @@ import net.corda.node.services.api.CheckpointStorage import net.corda.node.services.statemachine.Checkpoint import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX import net.corda.nodeapi.internal.persistence.currentDBSession -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.slf4j.Logger import org.slf4j.LoggerFactory import java.util.* diff --git a/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorage.kt b/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorage.kt index e2dd30acff..0f0bacde12 100644 --- a/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorage.kt +++ b/node/src/main/kotlin/net/corda/node/services/persistence/DBTransactionStorage.kt @@ -22,7 +22,7 @@ import net.corda.nodeapi.internal.persistence.CordaPersistence import net.corda.nodeapi.internal.persistence.NODE_DATABASE_PREFIX import net.corda.nodeapi.internal.persistence.bufferUntilDatabaseCommit import net.corda.nodeapi.internal.persistence.wrapWithDatabaseTransaction -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import rx.Observable import rx.subjects.PublishSubject import javax.persistence.* diff --git a/node/src/main/kotlin/net/corda/node/utilities/StateMachineManagerUtils.kt b/node/src/main/kotlin/net/corda/node/utilities/StateMachineManagerUtils.kt index d4cdf6b2d7..25ec223836 100644 --- a/node/src/main/kotlin/net/corda/node/utilities/StateMachineManagerUtils.kt +++ b/node/src/main/kotlin/net/corda/node/utilities/StateMachineManagerUtils.kt @@ -3,6 +3,7 @@ package net.corda.node.utilities import net.corda.core.flows.FlowLogic import net.corda.core.utilities.ProgressTracker import net.corda.node.services.statemachine.StateMachineManagerInternal +import org.apache.commons.lang3.reflect.FieldUtils import java.lang.reflect.Field /** @@ -59,17 +60,7 @@ private fun replaceTracker(newFlowLogic: FlowLogic<*>, oldProgressTracker: Progr } private fun getProgressTrackerField(newFlowLogic: FlowLogic<*>): Field? { - var clazz: Class<*> = newFlowLogic::class.java - var field: Field? = null // The progress tracker field may have been overridden in an abstract superclass, so we have to traverse up // the hierarchy. - while (clazz != FlowLogic::class.java) { - field = clazz.declaredFields.firstOrNull { it.name == "progressTracker" } - if (field == null) { - clazz = clazz.superclass - } else { - break - } - } - return field -} \ No newline at end of file + return FieldUtils.getAllFieldsList(newFlowLogic::class.java).find { it.name == "progressTracker" } +} diff --git a/serialization/src/test/kotlin/net/corda/serialization/internal/ContractAttachmentSerializerTest.kt b/serialization/src/test/kotlin/net/corda/serialization/internal/ContractAttachmentSerializerTest.kt index 0f33ff49bd..0d6ab382d5 100644 --- a/serialization/src/test/kotlin/net/corda/serialization/internal/ContractAttachmentSerializerTest.kt +++ b/serialization/src/test/kotlin/net/corda/serialization/internal/ContractAttachmentSerializerTest.kt @@ -10,7 +10,7 @@ import net.corda.testing.contracts.DummyContract import net.corda.testing.core.internal.CheckpointSerializationEnvironmentRule import net.corda.testing.internal.rigorousMock import net.corda.testing.node.MockServices -import org.apache.commons.lang.ArrayUtils.EMPTY_BYTE_ARRAY +import org.apache.commons.lang3.ArrayUtils.EMPTY_BYTE_ARRAY import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.Assert.assertArrayEquals diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalTestUtils.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalTestUtils.kt index de3b239c54..7408017067 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalTestUtils.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/InternalTestUtils.kt @@ -31,7 +31,7 @@ import net.corda.testing.node.InMemoryMessagingNetwork import net.corda.testing.node.TestCordapp import net.corda.testing.node.User import net.corda.testing.node.testContext -import org.apache.commons.lang.ClassUtils +import org.apache.commons.lang3.ClassUtils import org.assertj.core.api.Assertions.assertThat import org.slf4j.LoggerFactory import rx.Observable diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt index f6f527696d..48ed3c20cf 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/NodeBasedTest.kt @@ -24,7 +24,7 @@ import net.corda.testing.core.SerializationEnvironmentRule import net.corda.testing.driver.internal.incrementalPortAllocation import net.corda.testing.internal.testThreadFactory import net.corda.testing.node.User -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import org.apache.logging.log4j.Level import org.junit.After import org.junit.Before diff --git a/tools/cliutils/src/main/kotlin/net/corda/cliutils/InstallShellExtensionsParser.kt b/tools/cliutils/src/main/kotlin/net/corda/cliutils/InstallShellExtensionsParser.kt index 68a682e5e1..71546f4895 100644 --- a/tools/cliutils/src/main/kotlin/net/corda/cliutils/InstallShellExtensionsParser.kt +++ b/tools/cliutils/src/main/kotlin/net/corda/cliutils/InstallShellExtensionsParser.kt @@ -3,7 +3,7 @@ package net.corda.cliutils import net.corda.core.internal.* import net.corda.core.utilities.loggerFor import org.apache.commons.io.IOUtils -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import picocli.CommandLine import picocli.CommandLine.Command import java.nio.file.Path diff --git a/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt b/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt index 00494b8827..bb7bb32181 100644 --- a/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt +++ b/tools/explorer/src/main/kotlin/net/corda/explorer/Main.kt @@ -15,7 +15,7 @@ import net.corda.explorer.model.CordaViewModel import net.corda.explorer.model.SettingsModel import net.corda.explorer.views.* import net.corda.explorer.views.cordapps.cash.CashViewer -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import org.controlsfx.dialog.ExceptionDialog import tornadofx.App import tornadofx.addStageIcon diff --git a/tools/shell/src/main/kotlin/net/corda/tools/shell/utlities/ANSIProgressRenderer.kt b/tools/shell/src/main/kotlin/net/corda/tools/shell/utlities/ANSIProgressRenderer.kt index 6332566073..dad1d9d96a 100644 --- a/tools/shell/src/main/kotlin/net/corda/tools/shell/utlities/ANSIProgressRenderer.kt +++ b/tools/shell/src/main/kotlin/net/corda/tools/shell/utlities/ANSIProgressRenderer.kt @@ -4,7 +4,7 @@ import net.corda.core.internal.Emoji import net.corda.core.messaging.FlowProgressHandle import net.corda.core.utilities.loggerFor import net.corda.tools.shell.utlities.StdoutANSIProgressRenderer.draw -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.core.LogEvent import org.apache.logging.log4j.core.LoggerContext diff --git a/tools/shell/src/test/kotlin/net/corda/tools/shell/utilities/ANSIProgressRendererTest.kt b/tools/shell/src/test/kotlin/net/corda/tools/shell/utilities/ANSIProgressRendererTest.kt index 08dbe492c2..112de26350 100644 --- a/tools/shell/src/test/kotlin/net/corda/tools/shell/utilities/ANSIProgressRendererTest.kt +++ b/tools/shell/src/test/kotlin/net/corda/tools/shell/utilities/ANSIProgressRendererTest.kt @@ -7,7 +7,7 @@ import net.corda.core.messaging.DataFeed import net.corda.core.messaging.FlowProgressHandleImpl import net.corda.tools.shell.utlities.ANSIProgressRenderer import net.corda.tools.shell.utlities.CRaSHANSIProgressRenderer -import org.apache.commons.lang.SystemUtils +import org.apache.commons.lang3.SystemUtils import org.assertj.core.api.Assertions.assertThat import org.crsh.text.RenderPrintWriter import org.junit.Test