mirror of
https://github.com/corda/corda.git
synced 2025-06-23 01:19:00 +00:00
CORDA-2954: Upgrade to common-lang3 (#5152)
Utilised Fields.getAllFieldsList where we were doing the equivalent
This commit is contained in:
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.*
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user