Skip to content

A resource can be acquired even from the closed pool #290

@iRevive

Description

@iRevive

keypool version: 0.4.7

Even when the state of the pool is PoolClosed a new resource can still be acquired.
Should an exception be thrown at this case?

Example:

val pool = KeyPool
  .Builder(
    (i: Int) => IO.ref(i),
    (r: Ref[IO, Int]) => IO.unit
  )
  .build
  
for {
  closedPool <- pool.use(kp => IO.pure(kp)) 
  _          <- closedPool.take(1).use { ref => 
    ref.get.flatMap(value => IO.println(s"created a new ref in the closed pool: $value"))
  }
} yield ()

Output:

created a new ref in the closed pool: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions