Exposed converts Duration to its nanoseconds value when writing to database, and uses the kotlin Long.nanoseconds function to convert Long to Duration when reading from database. If inserting the Duration.INFINITE value, the saving value in database is 9223372036854775807(Long.MAX_VALUE). However, the kotlin Long.nanoseconds function checks Long.MAX_VALUE exceeding the nanosecond range and then converts it to millisecond unit, causing the ignoring of last few digits of the value. Therefore, the reading value does not equal to Duration.INFINITE anymore.
This bug can be fixed by first checking the equality of the value and Duration.INFINITE.inWholeNanoseconds, then return Duration.INFINITE directly if equals.
Fix EXPOSED-270.
Exposed converts Duration to its nanoseconds value when writing to database, and uses the kotlin
Long.nanoseconds
function to convert Long to Duration when reading from database. If inserting theDuration.INFINITE
value, the saving value in database is 9223372036854775807(Long.MAX_VALUE
). However, the kotlinLong.nanoseconds
function checksLong.MAX_VALUE
exceeding the nanosecond range and then converts it to millisecond unit, causing the ignoring of last few digits of the value. Therefore, the reading value does not equal toDuration.INFINITE
anymore.This bug can be fixed by first checking the equality of the value and
Duration.INFINITE.inWholeNanoseconds
, then returnDuration.INFINITE
directly if equals.