8000 fix PartitionedAsyncObjectPoolSpec factory can't return the same int … · antonzherdev/postgresql-async@01d7c70 · GitHub
[go: up one dir, main page]

Skip to content

Commit 01d7c70

Browse files
committed
fix PartitionedAsyncObjectPoolSpec factory can't return the same int twice to two different partitions
1 parent 77226d8 commit 01d7c70

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

db-async-common/src/test/scala/com/github/mauricio/async/db/pool/PartitionedAsyncObjectPoolSpec.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.mauricio< 8000 /span>.async.db.pool
22

3+
import java.util.concurrent.atomic.AtomicInteger
4+
35
import org.specs2.mutable.Specification
46
import scala.util.Try
57
import scala.concurrent.Await
@@ -17,17 +19,16 @@ class PartitionedAsyncObjectPoolSpec extends SpecificationWithJUnit {
1719

1820
val config =
1921
PoolConfiguration(100, Long.MaxValue, 100, Int.MaxValue)
20-
22+
private var current = new AtomicInteger
2123
val factory = new ObjectFactory[Int] {
2224
var reject = Set[Int]()
2325
var failCreate = false
24-
private var current = 0
26+
2527
def create =
2628
if (failCreate)
2729
throw new IllegalStateException
2830
else {
29-
current += 1
30-
current
31+
current.incrementAndGet()
3132
}
3233
def destroy(item: Int) = {}
3334
def validate(item: Int) =

0 commit comments

Comments
 (0)
0