From a4d00b79d4054805b7a52a87ae5220dde21cd207 Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Tue, 21 Jan 2020 09:05:23 +0000 Subject: [PATCH] CORDA-3377: Upgrade to DJVM 1.0-RC06. (#5866) --- constants.properties | 2 +- core-deterministic/build.gradle | 3 --- .../contracts/TransactionVerificationException.kt | 11 ++++++++++- .../internal/MissingSerializerException.kt | 6 ------ .../kotlin/net/corda/node/djvm/AttachmentBuilder.kt | 8 +++++++- serialization-deterministic/build.gradle | 3 --- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/constants.properties b/constants.properties index 1019f29656..c790d64017 100644 --- a/constants.properties +++ b/constants.properties @@ -30,7 +30,7 @@ snakeYamlVersion=1.19 caffeineVersion=2.7.0 metricsVersion=4.1.0 metricsNewRelicVersion=1.1.1 -djvmVersion=1.0-RC05 +djvmVersion=1.0-RC06 deterministicRtVersion=1.0-RC02 openSourceBranch=https://github.com/corda/corda/blob/release/os/4.4 openSourceSamplesBranch=https://github.com/corda/samples/blob/release-V4 diff --git a/core-deterministic/build.gradle b/core-deterministic/build.gradle index fdf49a66f7..5bf7b7afc2 100644 --- a/core-deterministic/build.gradle +++ b/core-deterministic/build.gradle @@ -208,9 +208,6 @@ publish { name jarBaseName } -// Must be after publish {} so that the previous install task exists for overwriting. -task install(overwrite: true, dependsOn: 'publishToMavenLocal') - idea { module { if (project.hasProperty("deterministic_idea_sdk")) { diff --git a/core/src/main/kotlin/net/corda/core/contracts/TransactionVerificationException.kt b/core/src/main/kotlin/net/corda/core/contracts/TransactionVerificationException.kt index d9fafe87fc..84571a9089 100644 --- a/core/src/main/kotlin/net/corda/core/contracts/TransactionVerificationException.kt +++ b/core/src/main/kotlin/net/corda/core/contracts/TransactionVerificationException.kt @@ -36,7 +36,16 @@ open class TransactionResolutionException @JvmOverloads constructor(val hash: Se * @property hash Hash of the bytes of the attachment, see [Attachment.id] */ @KeepForDJVM -class AttachmentResolutionException(val hash: SecureHash) : FlowException("Attachment resolution failure for $hash") +class AttachmentResolutionException(val hash: AttachmentId) : FlowException("Attachment resolution failure for $hash") + +/** + * A non-specific exception for the attachment identified by [attachmentId]. The context + * for this error is provided via the [message] and [cause]. + * @property attachmentId + */ +@KeepForDJVM +class BrokenAttachmentException(val attachmentId: AttachmentId, message: String?, cause: Throwable?) + : FlowException("Attachment $attachmentId has error (${message ?: "no message"})", cause) /** * Indicates that some aspect of the transaction named by [txId] violates the platform rules. The exact type of failure diff --git a/core/src/main/kotlin/net/corda/core/serialization/internal/MissingSerializerException.kt b/core/src/main/kotlin/net/corda/core/serialization/internal/MissingSerializerException.kt index 466a29a49c..600f4d77cc 100644 --- a/core/src/main/kotlin/net/corda/core/serialization/internal/MissingSerializerException.kt +++ b/core/src/main/kotlin/net/corda/core/serialization/internal/MissingSerializerException.kt @@ -15,10 +15,4 @@ open class MissingSerializerException private constructor( ) : NotSerializableException(message) { constructor(message: String, typeDescriptor: String) : this(message, typeDescriptor, emptyList()) constructor(message: String, typeNames: List) : this(message, null, typeNames) - - /** - * This constructor allows instances of this exception to escape the DJVM sandbox. - */ - @Suppress("unused") - private constructor(message: String) : this(message, null, emptyList()) } diff --git a/node/djvm/src/main/kotlin/net/corda/node/djvm/AttachmentBuilder.kt b/node/djvm/src/main/kotlin/net/corda/node/djvm/AttachmentBuilder.kt index d846ad08c9..f3a205ba38 100644 --- a/node/djvm/src/main/kotlin/net/corda/node/djvm/AttachmentBuilder.kt +++ b/node/djvm/src/main/kotlin/net/corda/node/djvm/AttachmentBuilder.kt @@ -2,6 +2,7 @@ package net.corda.node.djvm import net.corda.core.contracts.Attachment +import net.corda.core.contracts.BrokenAttachmentException import net.corda.core.crypto.SecureHash import net.corda.core.identity.Party import java.io.InputStream @@ -56,7 +57,12 @@ class SandboxAttachment( @Suppress("OverridingDeprecatedMember") override val signers: List = emptyList() + @Suppress("TooGenericExceptionCaught") override fun open(): InputStream { - return streamer.apply(attachment) + return try { + streamer.apply(attachment) + } catch (e: Exception) { + throw BrokenAttachmentException(id, e.message, e) + } } } diff --git a/serialization-deterministic/build.gradle b/serialization-deterministic/build.gradle index 7a17efd6a8..8bd7dc47a2 100644 --- a/serialization-deterministic/build.gradle +++ b/serialization-deterministic/build.gradle @@ -196,9 +196,6 @@ publish { name jarBaseName } -// Must be after publish {} so that the previous install task exists for overwriting. -task install(overwrite: true, dependsOn: 'publishToMavenLocal') - idea { module { if (project.hasProperty("deterministic_idea_sdk")) {