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
22 changed files with 32 additions and 45 deletions

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