Skip to content

Commit

Permalink
Merge branch 'main' into address-upload-artifact-deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
kennethshackleton committed Sep 1, 2024
2 parents eb5bea2 + 2204e07 commit 982af2f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class CommonObjectPool<K : Any, T : IPooledObject<K>>(
if (future?.isCancelled == false || configuration.evictionIntervalMillis < 0L || isClosed.get()) {
return
}
future = executor.scheduleAtFixedRate(
future = executor.scheduleWithFixedDelay(
::evict,
configuration.evictionDelayMillis,
configuration.evictionIntervalMillis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class SingleObjectPool<K : Any, T : IPooledObject<K>>(
if (evictionIntervalMillis < 0L || isClosed) {
return
}
future = executor.scheduleAtFixedRate(
future = executor.scheduleWithFixedDelay(
::evict,
evictionDelayMillis,
evictionIntervalMillis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,16 @@ internal class CommonObjectPoolTest {

@Test
fun interleavedBorrowSchedulesEvictionIfCancelled() {
@Suppress("JoinDeclarationAndAssignment")
lateinit var pool: CommonObjectPool<String, PooledObject>
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)
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -382,10 +382,8 @@ internal class SingleObjectPoolTest {

@Test
fun borrowAsClosingDoesNotScheduleEviction() {
@Suppress("JoinDeclarationAndAssignment")
lateinit var pool: SingleObjectPool<String, PooledObject>
val executor = mock<ScheduledExecutorService>()
pool = SingleObjectPool(object : IObjectFactory<PooledObject> {
val pool = SingleObjectPool(object : IObjectFactory<PooledObject> {
override fun close() = Unit

override fun destroyObject(obj: PooledObject) = Unit
Expand Down

0 comments on commit 982af2f

Please sign in to comment.