Skip to content

Commit 23aabb0

Browse files
committed
#809 Fix more PR suggestions, especially a potential integer overflow (Thanks @coderabbitai).
1 parent 27665e7 commit 23aabb0

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

cobol-parser/src/main/scala/za/co/absa/cobrix/cobol/reader/VarLenNestedReader.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,7 @@ class VarLenNestedReader[T: ClassTag](copybookContents: Seq[String],
217217

218218
private def getSplitSizeMB(isCompressed: Boolean): Option[Int] = {
219219
if (isCompressed) {
220-
readerProperties.inputSplitSizeCompressedMB match {
221-
case Some(size) => readerProperties.inputSplitSizeCompressedMB
222-
case None => Some(1024)
223-
}
220+
readerProperties.inputSplitSizeCompressedMB.orElse(Some(1024))
224221
} else {
225222
if (readerProperties.inputSplitSizeMB.isDefined) {
226223
readerProperties.inputSplitSizeMB

spark-cobol/src/main/scala/za/co/absa/cobrix/spark/cobol/source/streaming/BufferedFSDataInputStream.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class BufferedFSDataInputStream(filePath: Path, hadoopConfig: Configuration, sta
3838
private val buffer = new Array[Byte](bufferSizeInBytes)
3939
private var bufferPos = 0
4040
private var bufferContainBytes = 0
41-
private var bytesRead = 0
41+
private var bytesRead = 0L
4242

4343
@throws[IOException]
4444
def close(): Unit = {
@@ -67,7 +67,7 @@ class BufferedFSDataInputStream(filePath: Path, hadoopConfig: Configuration, sta
6767
if (bufferPos < bufferContainBytes) {
6868
val bytesLeft = bufferContainBytes - bufferPos
6969
System.arraycopy(buffer, bufferPos, b, off, bytesLeft)
70-
lengthLeft -= bufferContainBytes - bufferPos
70+
lengthLeft -= bytesLeft
7171
offsetLeft += bytesLeft
7272
}
7373
bufferPos = 0

0 commit comments

Comments
 (0)