Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iRevive opened this issue Nov 9, 2021 · 0 comments
Open

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

iRevive opened this issue Nov 9, 2021 · 0 comments

Comments

@iRevive
Copy link
Contributor

iRevive commented Nov 9, 2021

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
@iRevive iRevive changed the title A value can be acquired even from the closed pool A resource can be acquired even from the closed pool Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant