Skip to content

Commit 42fa4eb

Browse files
committed
Deduplicate 'handleFailures' call
1 parent 385167b commit 42fa4eb

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/BsonReaderInput.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BsonReaderInput(br: BsonReader, override val legacyOptionEncoding: Boolean
1717
override def readBoolean(): Boolean = br.readBoolean()
1818
override def readInt(): Int = br.readInt32()
1919
override def readLong(): Long = {
20-
if (bsonType == BsonType.INT32) br.readInt32().toLong // allow to treat INT32 as Long
20+
if (bsonType == BsonType.INT32) br.readInt32().toLong // allow converting INT32 to Long
2121
else br.readInt64()
2222
}
2323
override def readTimestamp(): Long = br.readDateTime()

commons-mongo/jvm/src/main/scala/com/avsystem/commons/mongo/BsonValueInput.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class BsonValueInput(bsonValue: BsonValue, override val legacyOptionEncoding: Bo
2222
def readString(): String = handleFailures(bsonValue.asString().getValue)
2323
def readBoolean(): Boolean = handleFailures(bsonValue.asBoolean().getValue)
2424
def readInt(): Int = handleFailures(bsonValue.asInt32().getValue)
25-
def readLong(): Long = {
26-
if (bsonType == BsonType.INT32) handleFailures(bsonValue.asInt32().getValue.toLong) // allow to treat INT32 as Long
27-
else handleFailures(bsonValue.asInt64().getValue)
25+
def readLong(): Long = handleFailures {
26+
if (bsonType == BsonType.INT32) bsonValue.asInt32().getValue.toLong // allow converting INT32 to Long
27+
else bsonValue.asInt64().getValue
2828
}
2929
override def readTimestamp(): Long = handleFailures(bsonValue.asDateTime().getValue)
3030
def readDouble(): Double = handleFailures(bsonValue.asDouble().getValue)

0 commit comments

Comments
 (0)