This is an automated email from the ASF dual-hosted git repository.
jadams pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-daffodil.git
The following commit(s) were added to refs/heads/master by this push:
new 1038ecb Alert user to use blobs instead of hexBinary
1038ecb is described below
commit 1038ecb1266632855fb1d1b513d4c8f0437ece7d
Author: Josh Adams <[email protected]>
AuthorDate: Tue Oct 13 15:51:40 2020 -0400
Alert user to use blobs instead of hexBinary
The test files provided for this bug were bumping into the limits of
integer values, which we cannot create an array that is larger than
Int.MaxValue. In cases such as this, blobs should be used instead. Given
that this error is originating from the official NITF schema, we should
update the NITF schema to take advantage of blobs for large payloads.
DAFFODIL-2401
---
.../scala/org/apache/daffodil/io/InputSourceDataInputStream.scala | 1 -
.../org/apache/daffodil/processors/parsers/BlobLengthParsers.scala | 2 ++
.../daffodil/processors/parsers/HexBinaryLengthParsers.scala | 7 +++++--
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git
a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala
b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala
index 5176538..af2c078 100644
---
a/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala
+++
b/daffodil-io/src/main/scala/org/apache/daffodil/io/InputSourceDataInputStream.scala
@@ -521,7 +521,6 @@ final class InputSourceDataInputStream private (val
inputSource: InputSource)
def skip(nBits: Long, finfo: FormatInfo): Boolean = {
// threadCheck()
- Assert.usage(nBits <= Int.MaxValue)
if (!this.isDefinedForLength(nBits)) return false
setBitPos0b(bitPos0b + nBits)
true
diff --git
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BlobLengthParsers.scala
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BlobLengthParsers.scala
index 6de45a7..b342ce3 100644
---
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BlobLengthParsers.scala
+++
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/BlobLengthParsers.scala
@@ -47,6 +47,8 @@ sealed abstract class BlobLengthParser(override val context:
ElementRuntimeData)
val array = new Array[Byte](start.tunable.blobChunkSizeInBytes)
val blobChunkSizeInBits = start.tunable.blobChunkSizeInBytes * 8
+ if (blobChunkSizeInBits > Int.MaxValue)
+ start.SDE("blobChunkSizeInBytes is too large. blobChunkSizeInBytes must
be less than " + (Int.MaxValue / 8))
while (remainingBitsToGet > 0) {
val bitsToGet = Math.min(remainingBitsToGet, blobChunkSizeInBits).toInt
diff --git
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
index 0efbc3a..f77349f 100644
---
a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
+++
b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/HexBinaryLengthParsers.scala
@@ -33,13 +33,16 @@ sealed abstract class HexBinaryLengthParser(override val
context: ElementRuntime
override final def parse(start: PState): Unit = {
val dis = start.dataInputStream
val currentElement = start.simpleElement
- val nBits = getLengthInBits(start).toInt
+ val nBits = getLengthInBits(start)
if (nBits == 0) {
currentElement.setDataValue(zeroLengthArray)
+ } else if (nBits > Int.MaxValue) {
+ // Integer overflow will occurr, recommend using blob instead of
hexBinary
+ PE(start, "Data is too large for xs:hexBinary. Consider using blobs
instead: https://s.apache.org/daffodil-blob-feature")
} else if (!dis.isDefinedForLength(nBits)) {
PENotEnoughBits(start, nBits, dis.remainingBits)
} else {
- val array = start.dataInputStream.getByteArray(nBits, start)
+ val array = start.dataInputStream.getByteArray(nBits.toInt, start)
currentElement.setDataValue(array)
}
}