diff --git a/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/CommonObjectPool.kt b/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/CommonObjectPool.kt index f70b2eafc3..2403c14107 100644 --- a/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/CommonObjectPool.kt +++ b/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/CommonObjectPool.kt @@ -181,7 +181,7 @@ class CommonObjectPool>( if (future?.isCancelled == false || configuration.evictionIntervalMillis < 0L || isClosed.get()) { return } - future = executor.scheduleAtFixedRate( + future = executor.scheduleWithFixedDelay( ::evict, configuration.evictionDelayMillis, configuration.evictionIntervalMillis, diff --git a/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/SingleObjectPool.kt b/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/SingleObjectPool.kt index eed41aaeaa..efbcc0a9a0 100644 --- a/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/SingleObjectPool.kt +++ b/selekt-java/src/main/kotlin/com/bloomberg/selekt/pools/SingleObjectPool.kt @@ -118,7 +118,7 @@ class SingleObjectPool>( if (evictionIntervalMillis < 0L || isClosed) { return } - future = executor.scheduleAtFixedRate( + future = executor.scheduleWithFixedDelay( ::evict, evictionDelayMillis, evictionIntervalMillis, diff --git a/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/CommonObjectPoolTest.kt b/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/CommonObjectPoolTest.kt index 69a6b64ba0..5a9645ac08 100644 --- a/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/CommonObjectPoolTest.kt +++ b/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/CommonObjectPoolTest.kt @@ -360,17 +360,16 @@ internal class CommonObjectPoolTest { @Test fun interleavedBorrowSchedulesEvictionIfCancelled() { - @Suppress("JoinDeclarationAndAssignment") lateinit var pool: CommonObjectPool val executor = object : ScheduledExecutorService by this@CommonObjectPoolTest.executor { var count = 0 - override fun scheduleAtFixedRate( + override fun scheduleWithFixedDelay( command: Runnable, initialDelay: Long, - period: Long, + delay: Long, unit: TimeUnit - ) = this@CommonObjectPoolTest.executor.scheduleAtFixedRate(command, initialDelay, period, unit).also { + ) = this@CommonObjectPoolTest.executor.scheduleWithFixedDelay(command, initialDelay, delay, unit).also { if (count++ == 0) { it.cancel(false) } @@ -459,12 +458,12 @@ internal class CommonObjectPoolTest { @Test fun evictionFailsIfCancelled() { val executor = object : ScheduledExecutorService by this@CommonObjectPoolTest.executor { - override fun scheduleAtFixedRate( + override fun scheduleWithFixedDelay( command: Runnable, initialDelay: Long, - period: Long, + delay: Long, unit: TimeUnit - ) = this@CommonObjectPoolTest.executor.scheduleAtFixedRate(command, initialDelay, period, unit).apply { + ) = this@CommonObjectPoolTest.executor.scheduleWithFixedDelay(command, initialDelay, delay, unit).apply { cancel(false) } } diff --git a/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/SingleObjectPoolTest.kt b/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/SingleObjectPoolTest.kt index c97f6ce830..6a2d544f34 100644 --- a/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/SingleObjectPoolTest.kt +++ b/selekt-java/src/test/kotlin/com/bloomberg/selekt/pools/SingleObjectPoolTest.kt @@ -349,12 +349,12 @@ internal class SingleObjectPoolTest { @Test fun evictionFailsIfCancelled() { val executor = object : ScheduledExecutorService by this@SingleObjectPoolTest.executor { - override fun scheduleAtFixedRate( + override fun scheduleWithFixedDelay( command: Runnable, initialDelay: Long, - period: Long, + delay: Long, unit: TimeUnit - ) = this@SingleObjectPoolTest.executor.scheduleAtFixedRate(command, initialDelay, period, unit).apply { + ) = this@SingleObjectPoolTest.executor.scheduleAtFixedRate(command, initialDelay, delay, unit).apply { cancel(false) } } @@ -382,10 +382,8 @@ internal class SingleObjectPoolTest { @Test fun borrowAsClosingDoesNotScheduleEviction() { - @Suppress("JoinDeclarationAndAssignment") - lateinit var pool: SingleObjectPool val executor = mock() - pool = SingleObjectPool(object : IObjectFactory { + val pool = SingleObjectPool(object : IObjectFactory { override fun close() = Unit override fun destroyObject(obj: PooledObject) = Unit