diff --git a/core/src/main/kotlin/net/corda/core/utilities/ByteArrays.kt b/core/src/main/kotlin/net/corda/core/utilities/ByteArrays.kt index 2b314a8772..7190e0c770 100644 --- a/core/src/main/kotlin/net/corda/core/utilities/ByteArrays.kt +++ b/core/src/main/kotlin/net/corda/core/utilities/ByteArrays.kt @@ -33,7 +33,7 @@ sealed class ByteSequence(private val _bytes: ByteArray, val offset: Int, val si fun open() = ByteArrayInputStream(_bytes, offset, size) /** - * Create a sub-sequence of this sequence. A copy of the underlying array may be made, if a subclass overrides + * Create a sub-sequence of this sequence. A copy of the underlying array may be made, if a subclass overrides * [bytes] to do so, as [OpaqueBytes] does. * * @param offset The offset within this sequence to start the new sequence. Note: not the offset within the backing array. @@ -41,10 +41,7 @@ sealed class ByteSequence(private val _bytes: ByteArray, val offset: Int, val si */ @Suppress("MemberVisibilityCanBePrivate") fun subSequence(offset: Int, size: Int): ByteSequence { - require(offset >= 0) - require(offset + size <= this.size) - // Intentionally use bytes rather than _bytes, in case a subclass wants to prevent access to the original - // underlying array which could be revealed here (e.g. OpaqueBytes). + // Intentionally use bytes rather than _bytes, to mirror the copy-or-not behaviour of that property. return if (offset == 0 && size == this.size) this else of(bytes, this.offset + offset, size) }