Skip to content

Commit

Permalink
Fix : Change maxRepetitionDelay and minRepetitionDelay values to mill…
Browse files Browse the repository at this point in the history
…iseconds.

Fix : Change KDocs to accomodate this change
  • Loading branch information
mgrati committed Jun 20, 2023
1 parent 44ef3fc commit c2c3c91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class DatabaseConfig private constructor(
*/
var defaultRepetitionAttempts: Int = 3,
/**
* The minimum time to wait before retrying a transaction if SQLException happens
* The minimum number of milliseconds to wait before retrying a transaction if SQLException happens
* Can be overridden on per-transaction level by specifying `minRepetitionDelay` parameter on call
* Default minimum delay is 0
*/
var defaultMinRepetitionDelay: Long = 0,
/**
* The maximum time to wait before retrying a transaction if SQLException happens
* The maximum number of milliseconds to wait before retrying a transaction if SQLException happens
* Can be overridden on per-transaction level by specifying `maxRepetitionDelay` parameter on call
* Default maximum delay is 0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,15 @@ fun <T> inTopLevelTransaction(
}
// set delay value
val delay = if (minRepetitionDelay < maxRepetitionDelay) {
minRepetitionDelay + Random(System.currentTimeMillis()).nextLong(maxRepetitionDelay - minRepetitionDelay)
Random(System.currentTimeMillis()).nextLong(minRepetitionDelay, maxRepetitionDelay)
} else if (minRepetitionDelay == maxRepetitionDelay) {
minRepetitionDelay
} else {
0
}
exposedLogger.warn("Wait $delay seconds before retrying")
exposedLogger.warn("Wait $delay milliseconds before retrying")
try {
Thread.sleep(delay * 1000)
Thread.sleep(delay)
} catch (e: InterruptedException) {
// Do nothing
}
Expand Down

0 comments on commit c2c3c91

Please sign in to comment.