mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-08-04 15:18:40 +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>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</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" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
@ -57,6 +57,14 @@ data class RetryPolicy(
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
val timesPerMinute = count.toFloat() / minutes.toFloat()
|
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
Add a link
Reference in a new issue