Move SSD truth cache guard to typed Kotlin
ober
c327bcf4d5520c2626650dbbe0c7a6d2db6c028a
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -1765,6 +1765,7 @@ nullableTextPresent nullableTextOrEmpty nullableTextOrDefault nullableByteCountPresent nullableByteCountOrZero nullableByteCountOrDefault nullableByteCountWithinLimit + nullableAnyPresent oldDestinationBytes urlEffectivePort constantTimeBytesEqual constantTimeBytesMismatch constantTimeNullableBytesEqual constantTimeNullableBytesMismatch @@ -1905,6 +1906,8 @@ (def (nullableByteCountWithinLimit (bytes : (Nullable Int)) (maxBytes : Int)) : Bool (byteCountWithinLimit (nullableByteCountOrZero bytes) maxBytes)) + (def (nullableAnyPresent (value : (Nullable Any))) : Bool + (not (nullable-null? value))) (def (storageEntryBytesAllowed (bytes : Int) (maxBytes : Int)) : Bool (byteCountWithinLimit bytes maxBytes)) (def (boundedReadLimitValid (limit : Int)) : Bool @@ -8649,7 +8652,7 @@ "" " @Synchronized" " private fun truthIndexEntries(): List<TruthIndexEntry> {" - " truthIndexCache?.let { return it }" + " if (nullableAnyPresent(truthIndexCache)) return checkNotNull(truthIndexCache)" " val entries = if (fileListFilesPresent(groundTruthDir)) {" " checkNotNull(groundTruthDir.listFiles { f -> truthJsonFileName(f.name) })" " .sortedBy { it.name }"