mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-04-20 03:25:14 +00:00
Avoid divide by zero crash in RetryPolicy
This commit is contained in:
parent
56030af0f0
commit
26ab76b363
2 changed files with 10 additions and 2 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -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">
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue