TM-23 Fail build on compiler warnings (#5453)

* java compile respects compilation.allWarningsAsErrors

* suppress or cleanup warnings

* suppress warning

* use non-deprecated kotlin dependency

* rename property

* handle property existence check

* Deal with warnings
This commit is contained in:
Zoltan Kiss
2019-09-11 16:34:51 +01:00
committed by Dominic Fox
parent 4e6edd012a
commit f171de7b69
75 changed files with 223 additions and 143 deletions

View File

@ -1,22 +1,27 @@
package net.corda.nodeapi.exceptions
import net.corda.core.ClientRelevantError
import net.corda.core.CordaRuntimeException
import net.corda.core.crypto.SecureHash
import net.corda.core.flows.IdentifiableException
import net.corda.core.serialization.CordaSerializable
/**
* Thrown to indicate that an attachment was already uploaded to a Corda node.
*/
class DuplicateAttachmentException(attachmentHash: String) : java.nio.file.FileAlreadyExistsException(attachmentHash), ClientRelevantError
class DuplicateAttachmentException(attachmentHash: String) :
java.nio.file.FileAlreadyExistsException(attachmentHash),
@Suppress("DEPRECATION") net.corda.core.ClientRelevantError
/**
* Thrown to indicate that a flow was not designed for RPC and should be started from an RPC client.
*/
class NonRpcFlowException(logicType: Class<*>) : IllegalArgumentException("${logicType.name} was not designed for RPC"), ClientRelevantError
class NonRpcFlowException(logicType: Class<*>) :
IllegalArgumentException("${logicType.name} was not designed for RPC"),
@Suppress("DEPRECATION") net.corda.core.ClientRelevantError
class OutdatedNetworkParameterHashException(old: SecureHash, new: SecureHash) : CordaRuntimeException(TEMPLATE.format(old, new)), ClientRelevantError {
class OutdatedNetworkParameterHashException(old: SecureHash, new: SecureHash) :
CordaRuntimeException(TEMPLATE.format(old, new)),
@Suppress("DEPRECATION") net.corda.core.ClientRelevantError
{
private companion object {
private const val TEMPLATE = "Refused to accept parameters with hash %s because network map advertises update with hash %s. Please check newest version"
@ -26,7 +31,9 @@ class OutdatedNetworkParameterHashException(old: SecureHash, new: SecureHash) :
/**
* Thrown to indicate that the command was rejected by the node, typically due to a special temporary mode.
*/
class RejectedCommandException(message: String) : CordaRuntimeException(message), ClientRelevantError
class RejectedCommandException(message: String) :
CordaRuntimeException(message),
@Suppress("DEPRECATION") net.corda.core.ClientRelevantError
/**
* Allows an implementing [Throwable] to be propagated to RPC clients.

View File

@ -54,7 +54,6 @@ class BCCryptoService(private val legalName: X500Principal, private val certific
}
}
@JvmOverloads
override fun sign(alias: String, data: ByteArray, signAlgorithm: String?): ByteArray {
try {
return when(signAlgorithm) {

View File

@ -55,15 +55,15 @@ class AttachmentVersionNumberMigration : CustomTaskChange {
}
availableAttachments.forEach { attachmentId ->
val versions = networkParameters?.whitelistedContractImplementations?.values.mapNotNull { it.indexOfFirst { it.toString() == attachmentId } }.filter { it >= 0 }
val versions = networkParameters.whitelistedContractImplementations.values.map { it.indexOfFirst { aid -> aid.toString() == attachmentId } }.filter { it >= 0 }
val maxPosition = versions.max() ?: 0
if (maxPosition > 0) {
val version = maxPosition + 1
val msg = "Updating version of attachment $attachmentId to '$version'."
val updateVersionMsg = "Updating version of attachment $attachmentId to '$version'."
if (versions.toSet().size > 1)
logger.warn("Several versions based on whitelistedContractImplementations position are available: ${versions.toSet()}. $msg")
logger.warn("Several versions based on whitelistedContractImplementations position are available: ${versions.toSet()}. $updateVersionMsg")
else
logger.info(msg)
logger.info(updateVersionMsg)
updateVersion(connection, attachmentId, version)
}
}
@ -88,8 +88,8 @@ class AttachmentVersionNumberMigration : CustomTaskChange {
private fun getNetworkParametersFromFile(path: Path): NetworkParameters? {
return try {
val networkParametersBytes = path?.readObject<SignedNetworkParameters>()
networkParametersBytes?.raw?.deserialize()
val networkParametersBytes = path.readObject<SignedNetworkParameters>()
networkParametersBytes.raw.deserialize()
} catch (e: Exception) {
// This condition is logged in the calling function, so no need to do that here.
null

View File

@ -269,6 +269,7 @@ class CordaPersistence(
(_dataSource as? AutoCloseable)?.close()
}
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
val hikariPoolThreadLocal: ThreadLocal<List<Object>>? by lazy(LazyThreadSafetyMode.PUBLICATION) {
val hikariDataSource = dataSource as? HikariDataSource
if (hikariDataSource == null) {
@ -279,9 +280,11 @@ class CordaPersistence(
val pool: HikariPool = poolField.get(hikariDataSource) as HikariPool
val connectionBagField: Field = HikariPool::class.java.getDeclaredField("connectionBag")
connectionBagField.isAccessible = true
@Suppress("UNCHECKED_CAST")
val connectionBag: ConcurrentBag<ConcurrentBag.IConcurrentBagEntry> = connectionBagField.get(pool) as ConcurrentBag<ConcurrentBag.IConcurrentBagEntry>
val threadListField: Field = ConcurrentBag::class.java.getDeclaredField("threadList")
threadListField.isAccessible = true
@Suppress("UNCHECKED_CAST")
val threadList: ThreadLocal<List<Object>> = threadListField.get(connectionBag) as ThreadLocal<List<Object>>
threadList
}

View File

@ -132,6 +132,7 @@ class HibernateConfiguration(
ClassLoaderServiceImpl(customClassLoader))
}
@Suppress("DEPRECATION")
val metadataBuilder = metadataSources.getMetadataBuilder(config.standardServiceRegistryBuilder.build())
val metadata = buildHibernateMetadata(metadataBuilder, jdbcUrl, attributeConverters)
return metadata.sessionFactoryBuilder.run {

View File

@ -118,6 +118,7 @@ class DelegatingStatisticsService(private val delegate: Statistics) : Statistics
return delegate.naturalIdCachePutCount
}
@Suppress("DEPRECATION")
override fun getNaturalIdCacheStatistics(arg0: String): NaturalIdCacheStatistics {
return delegate.getNaturalIdCacheStatistics(arg0)
}
@ -190,6 +191,7 @@ class DelegatingStatisticsService(private val delegate: Statistics) : Statistics
return delegate.secondLevelCacheRegionNames
}
@Suppress("DEPRECATION")
override fun getSecondLevelCacheStatistics(arg0: String): SecondLevelCacheStatistics {
return delegate.getSecondLevelCacheStatistics(arg0)
}