mirror of
https://github.com/corda/corda.git
synced 2024-12-24 07:06:44 +00:00
ENT-11351 - Compiler warnings pass 2 (#7655)
* Addressed compiler warnings * Removed unchecked cast fixes - not for this PR * Sorted out detekt issues
This commit is contained in:
parent
a0ce265b35
commit
f15e6ec56a
@ -61,7 +61,7 @@ class SpecificationTest {
|
||||
|
||||
override fun parseValid(configuration: Config, options: Configuration.Options): Valid<AtomicLong> {
|
||||
val config = configuration.withOptions(options)
|
||||
return valid(AtomicLong(config[maxElement]!!))
|
||||
return valid(AtomicLong(config[maxElement]))
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ class SpecificationTest {
|
||||
if (elements.any { element -> element <= 1 }) {
|
||||
return invalid(Configuration.Validation.Error.BadValue.of("elements cannot be less than or equal to 1"))
|
||||
}
|
||||
return valid(elements.max()!!)
|
||||
return valid(elements.max())
|
||||
}
|
||||
|
||||
val spec = object : Configuration.Specification<AtomicLong>("AtomicLong") {
|
||||
|
@ -56,8 +56,8 @@ class AmountTests {
|
||||
val splits = baseAmount.splitEvenly(partitionCount)
|
||||
assertEquals(partitionCount, splits.size)
|
||||
assertEquals(baseAmount, splits.sumOrZero(baseAmount.token))
|
||||
val min = splits.min()!!
|
||||
val max = splits.max()!!
|
||||
val min = splits.min()
|
||||
val max = splits.max()
|
||||
assertTrue(max.quantity - min.quantity <= 1L, "Amount quantities should differ by at most one token")
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ class CompatibleTransactionTests {
|
||||
ftxCompatibleNoInputs.verify()
|
||||
assertFailsWith<ComponentVisibilityException> { ftxCompatibleNoInputs.checkAllComponentsVisible(INPUTS_GROUP) }
|
||||
assertEquals(wireTransactionCompatibleA.componentGroups.size - 1, ftxCompatibleNoInputs.filteredComponentGroups.size)
|
||||
assertEquals(wireTransactionCompatibleA.componentGroups.map { it.groupIndex }.max()!!, ftxCompatibleNoInputs.groupHashes.size - 1)
|
||||
assertEquals(wireTransactionCompatibleA.componentGroups.map { it.groupIndex }.max(), ftxCompatibleNoInputs.groupHashes.size - 1)
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
|
@ -13,7 +13,8 @@ import net.corda.testing.core.SerializationEnvironmentRule
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
object EmptyWhitelist : ClassWhitelist {
|
||||
override fun hasListed(type: Class<*>): Boolean = false
|
||||
@ -23,9 +24,6 @@ class KotlinUtilsTest {
|
||||
@Rule
|
||||
@JvmField
|
||||
val testSerialization = SerializationEnvironmentRule()
|
||||
@JvmField
|
||||
@Rule
|
||||
val expectedEx: ExpectedException = ExpectedException.none()
|
||||
|
||||
private val KRYO_CHECKPOINT_NOWHITELIST_CONTEXT = CheckpointSerializationContextImpl(
|
||||
javaClass.classLoader,
|
||||
@ -54,11 +52,12 @@ class KotlinUtilsTest {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `deserialise transient property with non-capturing lambda`() {
|
||||
expectedEx.expect(KryoException::class.java)
|
||||
expectedEx.expectMessage("is not annotated or on the whitelist, so cannot be used in serialization")
|
||||
val anException = assertThrows<KryoException> {
|
||||
val original = NonCapturingTransientProperty()
|
||||
original.checkpointSerialize(context = KRYO_CHECKPOINT_CONTEXT).checkpointDeserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
|
||||
}
|
||||
anException.message?.let { assertTrue(it.contains("is not annotated or on the whitelist, so cannot be used in serialization")) }
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `checkpointing a transient property with capturing lambda`() {
|
||||
@ -73,13 +72,12 @@ class KotlinUtilsTest {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `deserialise transient property with capturing lambda`() {
|
||||
expectedEx.expect(KryoException::class.java)
|
||||
expectedEx.expectMessage("is not annotated or on the whitelist, so cannot be used in serialization")
|
||||
|
||||
val anException = assertThrows<KryoException> {
|
||||
val original = CapturingTransientProperty("Hello")
|
||||
|
||||
original.checkpointSerialize(context = KRYO_CHECKPOINT_CONTEXT).checkpointDeserialize(context = KRYO_CHECKPOINT_NOWHITELIST_CONTEXT)
|
||||
}
|
||||
anException.message?.let { assertTrue(it.contains("is not annotated or on the whitelist, so cannot be used in serialization")) }
|
||||
}
|
||||
|
||||
private class NullTransientProperty {
|
||||
var evalCount = 0
|
||||
|
@ -5,16 +5,12 @@ import net.corda.core.internal.lazyMapped
|
||||
import net.corda.core.internal.TransactionDeserialisationException
|
||||
import net.corda.core.internal.eagerDeserialise
|
||||
import net.corda.core.serialization.MissingAttachmentsException
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class LazyMappedListTest {
|
||||
|
||||
@get:Rule
|
||||
val exception: ExpectedException = ExpectedException.none()
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `LazyMappedList works`() {
|
||||
val originalList = (1 until 10).toList()
|
||||
@ -44,15 +40,14 @@ class LazyMappedListTest {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun testMissingAttachments() {
|
||||
exception.expect(MissingAttachmentsException::class.java)
|
||||
exception.expectMessage("Uncatchable!")
|
||||
|
||||
val anException = assertThrows<MissingAttachmentsException> {
|
||||
val lazyList = (0 until 5).toList().lazyMapped<Int, Int> { _, _ ->
|
||||
throw MissingAttachmentsException(emptyList(), "Uncatchable!")
|
||||
}
|
||||
|
||||
lazyList.eagerDeserialise { _, _ -> -999 }
|
||||
}
|
||||
assertEquals("Uncatchable!", anException.message)
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun testDeserialisationExceptions() {
|
||||
|
@ -40,7 +40,7 @@ import org.junit.After
|
||||
import org.junit.AfterClass
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
@ -54,16 +54,13 @@ import kotlin.io.path.readBytes
|
||||
import kotlin.io.path.useDirectoryEntries
|
||||
import kotlin.io.path.writeBytes
|
||||
import kotlin.io.path.writeText
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class NetworkBootstrapperTest {
|
||||
@Rule
|
||||
@JvmField
|
||||
val tempFolder = TemporaryFolder()
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val expectedEx: ExpectedException = ExpectedException.none()
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val testSerialization = SerializationEnvironmentRule()
|
||||
@ -304,10 +301,11 @@ class NetworkBootstrapperTest {
|
||||
assertContainsPackageOwner("alice", mapOf(Pair(greedyNamespace, alice.publicKey)))
|
||||
// register overlapping package name
|
||||
createNodeConfFile("bob", bobConfig)
|
||||
expectedEx.expect(IllegalArgumentException::class.java)
|
||||
expectedEx.expectMessage("Multiple packages added to the packageOwnership overlap.")
|
||||
val anException = assertThrows<IllegalArgumentException> {
|
||||
bootstrap(packageOwnership = mapOf(Pair(greedyNamespace, alice.publicKey), Pair(bobPackageName, bob.publicKey)))
|
||||
}
|
||||
assertEquals("Multiple packages added to the packageOwnership overlap.", anException.message)
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `unregister single package namespace in network of one`() {
|
||||
|
@ -60,7 +60,7 @@ class NodeStatePersistenceTests {
|
||||
result
|
||||
}
|
||||
assertNotNull(stateAndRef)
|
||||
val retrievedMessage = stateAndRef!!.state.data.message
|
||||
val retrievedMessage = stateAndRef.state.data.message
|
||||
assertEquals(message, retrievedMessage)
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ class NodeStatePersistenceTests {
|
||||
result
|
||||
}
|
||||
assertNotNull(stateAndRef)
|
||||
val retrievedMessage = stateAndRef!!.state.data.message
|
||||
val retrievedMessage = stateAndRef.state.data.message
|
||||
assertEquals(message, retrievedMessage)
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ class NodeRegistrationTest {
|
||||
pollInterval = 1.seconds,
|
||||
hostAndPort = portAllocation.nextHostAndPort(),
|
||||
myHostNameValue = "localhost",
|
||||
additionalServices = *arrayOf(registrationHandler))
|
||||
additionalServices = arrayOf(registrationHandler))
|
||||
serverHostAndPort = server.start()
|
||||
}
|
||||
|
||||
|
@ -306,11 +306,11 @@ class StaffedFlowHospital(private val flowMessaging: FlowMessaging,
|
||||
log.info("Error ${index + 1} of ${errors.size}:", error)
|
||||
val diagnoses: Map<Diagnosis, List<Staff>> = staff.groupBy { it.consult(flowFiber, currentState, error, medicalHistory) }
|
||||
// We're only interested in the highest priority diagnosis for the error
|
||||
val (diagnosis, by) = diagnoses.entries.minBy { it.key }!!
|
||||
val (diagnosis, by) = diagnoses.entries.minBy { it.key }
|
||||
ConsultationReport(error, diagnosis, by)
|
||||
}
|
||||
// And we're only interested in the error with the highest priority diagnosis
|
||||
.minBy { it.diagnosis }!!
|
||||
.minBy { it.diagnosis }
|
||||
}
|
||||
|
||||
private data class ConsultationReport(val error: Throwable, val diagnosis: Diagnosis, val by: List<Staff>)
|
||||
|
@ -412,7 +412,7 @@ class FlowMetadataRecordingTest {
|
||||
metadata!!.let {
|
||||
assertNull(it.finishInstant)
|
||||
assertNotNull(finishTime)
|
||||
assertTrue(finishTime!! >= it.startInstant)
|
||||
assertTrue(finishTime >= it.startInstant)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import net.corda.testing.core.*
|
||||
import net.corda.testing.internal.vault.DummyLinearStateSchemaV1
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.*
|
||||
import org.junit.rules.ExpectedException
|
||||
|
||||
class VaultQueryExceptionsTests : VaultQueryParties by rule {
|
||||
|
||||
@ -30,10 +29,6 @@ class VaultQueryExceptionsTests : VaultQueryParties by rule {
|
||||
}
|
||||
}
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val expectedEx: ExpectedException = ExpectedException.none()
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val rollbackRule = VaultQueryRollbackRule(this)
|
||||
|
@ -45,7 +45,8 @@ import org.junit.ClassRule
|
||||
import org.junit.Ignore
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.junit.rules.ExternalResource
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
@ -148,7 +149,7 @@ open class VaultQueryTestRule(private val persistentServices: Boolean) : Externa
|
||||
cordappPackages,
|
||||
makeTestIdentityService(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, dummyCashIssuer.identity, dummyNotary.identity),
|
||||
megaCorp,
|
||||
moreKeys = *arrayOf(DUMMY_NOTARY_KEY)
|
||||
moreKeys = arrayOf(DUMMY_NOTARY_KEY)
|
||||
)
|
||||
}
|
||||
database = databaseAndServices.first
|
||||
@ -184,10 +185,6 @@ class VaultQueryRollbackRule(private val vaultQueryParties: VaultQueryParties) :
|
||||
|
||||
abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val expectedEx: ExpectedException = ExpectedException.none()
|
||||
|
||||
companion object {
|
||||
@ClassRule @JvmField
|
||||
val testSerialization = SerializationEnvironmentRule()
|
||||
@ -1006,11 +1003,12 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
assertThat(resultsUnlockedAndByLockIds.states).hasSize(5)
|
||||
|
||||
// missing lockId
|
||||
expectedEx.expect(VaultQueryException::class.java)
|
||||
expectedEx.expectMessage("Must specify one or more lockIds")
|
||||
val anException = assertThrows<VaultQueryException> {
|
||||
val criteriaMissingLockId = VaultQueryCriteria(softLockingCondition = SoftLockingCondition(SoftLockingType.UNLOCKED_AND_SPECIFIED))
|
||||
vaultService.queryBy<ContractState>(criteriaMissingLockId)
|
||||
}
|
||||
anException.message?.let { assertTrue(it.contains("Must specify one or more lockIds")) }
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
@ -1707,25 +1705,22 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
// pagination: invalid page number
|
||||
@Test(timeout=300_000)
|
||||
fun `invalid page number`() {
|
||||
expectedEx.expect(VaultQueryException::class.java)
|
||||
expectedEx.expectMessage("Page specification: invalid page number")
|
||||
|
||||
val anException = assertThrows<VaultQueryException> {
|
||||
database.transaction {
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, notaryServices, 100, DUMMY_CASH_ISSUER)
|
||||
val pagingSpec = PageSpecification(0, 10)
|
||||
|
||||
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||
vaultService.queryBy<ContractState>(criteria, paging = pagingSpec)
|
||||
}
|
||||
}
|
||||
anException.message?.let { assertTrue(it.contains("Page specification: invalid page number")) }
|
||||
}
|
||||
|
||||
// pagination: invalid page size
|
||||
@Suppress("INTEGER_OVERFLOW")
|
||||
@Test(timeout=300_000)
|
||||
fun `invalid page size`() {
|
||||
expectedEx.expect(VaultQueryException::class.java)
|
||||
expectedEx.expectMessage("Page specification: invalid page size")
|
||||
|
||||
val anException = assertThrows<VaultQueryException> {
|
||||
database.transaction {
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, notaryServices, 100, DUMMY_CASH_ISSUER)
|
||||
val pagingSpec = PageSpecification(DEFAULT_PAGE_NUM, Integer.MAX_VALUE + 1) // overflow = -2147483648
|
||||
@ -1733,19 +1728,21 @@ abstract class VaultQueryTestsBase : VaultQueryParties {
|
||||
vaultService.queryBy<ContractState>(criteria, paging = pagingSpec)
|
||||
}
|
||||
}
|
||||
anException.message?.let { assertTrue(it.contains("Page specification: invalid page size")) }
|
||||
}
|
||||
|
||||
// pagination not specified but more than DEFAULT_PAGE_SIZE results available (fail-fast test)
|
||||
@Test(timeout=300_000)
|
||||
fun `pagination not specified but more than default results available`() {
|
||||
expectedEx.expect(VaultQueryException::class.java)
|
||||
expectedEx.expectMessage("provide a PageSpecification")
|
||||
|
||||
val anException = assertThrows<VaultQueryException> {
|
||||
database.transaction {
|
||||
vaultFiller.fillWithSomeTestCash(201.DOLLARS, notaryServices, 201, DUMMY_CASH_ISSUER)
|
||||
val criteria = VaultQueryCriteria(status = Vault.StateStatus.ALL)
|
||||
vaultService.queryBy<ContractState>(criteria)
|
||||
}
|
||||
}
|
||||
anException.message?.let { assertTrue(it.contains("provide a PageSpecification")) }
|
||||
}
|
||||
|
||||
// example of querying states with paging using totalStatesAvailable
|
||||
private fun queryStatesWithPaging(vaultService: VaultService, pageSize: Int): List<StateAndRef<ContractState>> {
|
||||
|
@ -83,7 +83,7 @@ class VaultWithCashTest {
|
||||
makeTestIdentityService(MEGA_CORP_IDENTITY, MINI_CORP_IDENTITY, dummyCashIssuer.identity, dummyNotary.identity),
|
||||
TestIdentity(MEGA_CORP.name, servicesKey),
|
||||
networkParameters,
|
||||
moreKeys = *arrayOf(dummyNotary.keyPair))
|
||||
moreKeys = arrayOf(dummyNotary.keyPair))
|
||||
database = databaseAndServices.first
|
||||
services = databaseAndServices.second
|
||||
vaultFiller = VaultFiller(services, dummyNotary)
|
||||
|
@ -131,7 +131,7 @@ object SimmFlow {
|
||||
|
||||
val valuer = serviceHub.identityService.wellKnownPartyFromAnonymous(state.valuer)
|
||||
require(valuer != null) { "Valuer party must be known to this node" }
|
||||
val valuation = agreeValuation(portfolio, valuationDate, valuer!!)
|
||||
val valuation = agreeValuation(portfolio, valuationDate, valuer)
|
||||
val update = PortfolioState.Update(valuation = valuation)
|
||||
return subFlow(StateRevisionFlowRequester(otherPartySession, stateRef, update)).state.data
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ object SimmRevaluation {
|
||||
if (ourIdentity == curState.participants[0]) {
|
||||
val otherParty = serviceHub.identityService.wellKnownPartyFromAnonymous(curState.participants[1])
|
||||
require(otherParty != null) { "Other party must be known by this node" }
|
||||
subFlow(SimmFlow.Requester(otherParty!!, valuationDate, stateAndRef))
|
||||
subFlow(SimmFlow.Requester(otherParty, valuationDate, stateAndRef))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +25,8 @@ import net.corda.testing.internal.TestingNamedCacheFactory
|
||||
import net.corda.testing.internal.services.InternalMockAttachmentStorage
|
||||
import net.corda.testing.services.MockAttachmentStorage
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.ExpectedException
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.mockito.kotlin.any
|
||||
import org.mockito.kotlin.doReturn
|
||||
import org.mockito.kotlin.verify
|
||||
@ -267,17 +266,16 @@ class CordaClassResolverTests {
|
||||
}
|
||||
|
||||
// Blacklist tests. Note: leave the variable public or else expected messages do not work correctly
|
||||
@get:Rule
|
||||
val expectedEx = ExpectedException.none()!!
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check blacklisted class`() {
|
||||
expectedEx.expect(IllegalStateException::class.java)
|
||||
expectedEx.expectMessage("Class java.util.HashSet is blacklisted, so it cannot be used in serialization.")
|
||||
val anException = assertThrows<IllegalStateException> {
|
||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||
// HashSet is blacklisted.
|
||||
resolver.getRegistration(HashSet::class.java)
|
||||
}
|
||||
assertEquals("Class java.util.HashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Kotlin EmptyList not registered`() {
|
||||
@ -349,46 +347,52 @@ class CordaClassResolverTests {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check blacklisted subclass`() {
|
||||
expectedEx.expect(IllegalStateException::class.java)
|
||||
expectedEx.expectMessage("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubHashSet is blacklisted, so it cannot be used in serialization.")
|
||||
val anException = assertThrows<IllegalStateException> {
|
||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||
// SubHashSet extends the blacklisted HashSet.
|
||||
resolver.getRegistration(SubHashSet::class.java)
|
||||
}
|
||||
assertEquals("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubHashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||
}
|
||||
|
||||
class SubSubHashSet<E> : SubHashSet<E>()
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check blacklisted subsubclass`() {
|
||||
expectedEx.expect(IllegalStateException::class.java)
|
||||
expectedEx.expectMessage("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubSubHashSet is blacklisted, so it cannot be used in serialization.")
|
||||
val anException = assertThrows<IllegalStateException> {
|
||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||
// SubSubHashSet extends SubHashSet, which extends the blacklisted HashSet.
|
||||
resolver.getRegistration(SubSubHashSet::class.java)
|
||||
}
|
||||
assertEquals("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$SubSubHashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||
|
||||
}
|
||||
|
||||
class ConnectionImpl(private val connection: Connection) : Connection by connection
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check blacklisted interface impl`() {
|
||||
expectedEx.expect(IllegalStateException::class.java)
|
||||
expectedEx.expectMessage("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$ConnectionImpl is blacklisted, so it cannot be used in serialization.")
|
||||
val anException = assertThrows<IllegalStateException> {
|
||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||
// ConnectionImpl implements blacklisted Connection.
|
||||
resolver.getRegistration(ConnectionImpl::class.java)
|
||||
}
|
||||
assertEquals("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$ConnectionImpl is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||
}
|
||||
|
||||
interface SubConnection : Connection
|
||||
class SubConnectionImpl(private val subConnection: SubConnection) : SubConnection by subConnection
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check blacklisted super-interface impl`() {
|
||||
expectedEx.expect(IllegalStateException::class.java)
|
||||
expectedEx.expectMessage("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$SubConnectionImpl is blacklisted, so it cannot be used in serialization.")
|
||||
val anException = assertThrows<IllegalStateException> {
|
||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||
// SubConnectionImpl implements SubConnection, which extends the blacklisted Connection.
|
||||
resolver.getRegistration(SubConnectionImpl::class.java)
|
||||
}
|
||||
assertEquals("The superinterface java.sql.Connection of net.corda.serialization.internal.CordaClassResolverTests\$SubConnectionImpl is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||
|
||||
}
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check forcibly allowed`() {
|
||||
@ -402,10 +406,11 @@ class CordaClassResolverTests {
|
||||
|
||||
@Test(timeout=300_000)
|
||||
fun `Check blacklist precedes CordaSerializable`() {
|
||||
expectedEx.expect(IllegalStateException::class.java)
|
||||
expectedEx.expectMessage("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$CordaSerializableHashSet is blacklisted, so it cannot be used in serialization.")
|
||||
val anException = assertThrows<IllegalStateException> {
|
||||
val resolver = CordaClassResolver(allButBlacklistedContext)
|
||||
// CordaSerializableHashSet is @CordaSerializable, but extends the blacklisted HashSet.
|
||||
resolver.getRegistration(CordaSerializableHashSet::class.java)
|
||||
}
|
||||
assertEquals("The superclass java.util.HashSet of net.corda.serialization.internal.CordaClassResolverTests\$CordaSerializableHashSet is blacklisted, so it cannot be used in serialization.", anException.message)
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ private class SpectatorDefaultAnswer : DefaultAnswer() {
|
||||
?: method.returnType!!
|
||||
}
|
||||
|
||||
private fun newSpectator(invocation: InvocationOnMock) = spectator(type)!!.also { log.info("New spectator {} for: {}", it, invocation.arguments) }
|
||||
private fun newSpectator(invocation: InvocationOnMock) = spectator(type).also { log.info("New spectator {} for: {}", it, invocation.arguments) }
|
||||
private val spectators = try {
|
||||
val first = newSpectator(invocation)
|
||||
ConcurrentHashMap<InvocationOnMock, Any>().apply { put(invocation, first) }
|
||||
|
@ -232,7 +232,7 @@ class NetworkMapServer(private val pollInterval: Duration,
|
||||
null
|
||||
}
|
||||
requireNotNull(requestedParameters)
|
||||
return Response.ok(requestedParameters!!.serialize().bytes).build()
|
||||
return Response.ok(requestedParameters.serialize().bytes).build()
|
||||
}
|
||||
|
||||
@GET
|
||||
|
@ -57,7 +57,7 @@ class TransactionViewer : CordaView("Transactions") {
|
||||
override val widgets = listOf(CordaWidget(title, TransactionWidget(), icon)).observable()
|
||||
|
||||
private var scrollPosition: Int = 0
|
||||
private lateinit var expander: ExpanderColumn<TransactionViewer.Transaction>
|
||||
private var expander: ExpanderColumn<TransactionViewer.Transaction>
|
||||
private var txIdToScroll: SecureHash? = null // Passed as param.
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ class NodeConnection(val remoteNode: RemoteNode, private val jSchSession: Sessio
|
||||
val connection = rpcConnection
|
||||
require(connection != null) { "doWhileClientStopped called with no running client" }
|
||||
log.info("Stopping RPC proxy to ${remoteNode.hostname}, tunnel at $localTunnelAddress")
|
||||
connection!!.close()
|
||||
connection.close()
|
||||
try {
|
||||
return action()
|
||||
} finally {
|
||||
|
Loading…
Reference in New Issue
Block a user