Avoid divide by zero crash in RetryPolicy

This commit is contained in:
Aidan Follestad 2019-01-08 10:46:02 -08:00
parent 56030af0f0
commit 26ab76b363
2 changed files with 10 additions and 2 deletions

2
.idea/misc.xml generated
View file

@ -40,7 +40,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

View file

@ -57,6 +57,14 @@ data class RetryPolicy(
return -1
}
val timesPerMinute = count.toFloat() / minutes.toFloat()
return MINUTE / timesPerMinute.toInt()
return MINUTE / timesPerMinute.toSafeInt()
}
private fun Float.toSafeInt(): Int {
val intValue = toInt()
if (intValue == 0) {
return 1
}
return intValue
}
}