CORDA-2954: Upgrade to common-lang3 (#5152)

Utilised Fields.getAllFieldsList where we were doing the equivalent
This commit is contained in:
Shams Asari 2019-05-21 17:48:32 +01:00 committed by GitHub
parent 79616536d4
commit 71c316ca5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 32 additions and 45 deletions

6
.idea/compiler.xml generated
View File

@ -37,6 +37,8 @@
<module name="cliutils_test" target="1.8" />
<module name="common-configuration-parsing_main" target="1.8" />
<module name="common-configuration-parsing_test" target="1.8" />
<module name="common-logging_main" target="1.8" />
<module name="common-logging_test" target="1.8" />
<module name="common-validation_main" target="1.8" />
<module name="common-validation_test" target="1.8" />
<module name="confidential-identities_main" target="1.8" />
@ -177,6 +179,8 @@
<module name="net.corda_buildSrc_test" target="1.8" />
<module name="net.corda_canonicalizer_main" target="1.8" />
<module name="net.corda_canonicalizer_test" target="1.8" />
<module name="netparams_main" target="1.8" />
<module name="netparams_test" target="1.8" />
<module name="network-bootstrapper_main" target="1.8" />
<module name="network-bootstrapper_test" target="1.8" />
<module name="network-verifier-contracts_main" target="1.8" />
@ -200,6 +204,8 @@
<module name="node_main" target="1.8" />
<module name="node_smokeTest" target="1.8" />
<module name="node_test" target="1.8" />
<module name="nodeinfo_main" target="1.8" />
<module name="nodeinfo_test" target="1.8" />
<module name="notary-bft-smart_main" target="1.8" />
<module name="notary-bft-smart_test" target="1.8" />
<module name="notary-demo-contracts_main" target="1.8" />

View File

@ -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"

View File

@ -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

View File

@ -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<FieldWithObject>().apply { addAllFields(state) }
// Get fields of class and all super-classes.
private fun getAllFields(clazz: Class<*>): List<Field> {
val fields = mutableListOf<Field>()
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<FieldWithObject>.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.

View File

@ -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.*

View File

@ -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

View File

@ -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

View File

@ -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.*

View File

@ -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
}

View File

@ -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.*

View File

@ -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

View File

@ -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

View File

@ -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.*

View File

@ -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.*

View File

@ -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
}
return FieldUtils.getAllFieldsList(newFlowLogic::class.java).find { it.name == "progressTracker" }
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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