Skip to content

Commit

Permalink
resources: Only mutate test mock objects inside synchronized blocks. (
Browse files Browse the repository at this point in the history
#9869)

That was silly.

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
SamirTalwar authored Jun 1, 2021
1 parent 3a0b2f9 commit d7c60f5
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,15 @@ final class ResourceOwnerSpec extends AsyncWordSpec with Matchers {
val owners = (1 to 10).map(value =>
new AbstractResourceOwner[TestContext, Int] {
override def acquire()(implicit context: TestContext): Resource[Int] = {
acquireOrder += value
acquireOrder.synchronized {
acquireOrder += value
}
Resource(Future(value))(v =>
Future {
released += v
released.synchronized {
released += v
}
()
}
)
}
Expand Down Expand Up @@ -747,11 +752,16 @@ final class ResourceOwnerSpec extends AsyncWordSpec with Matchers {
new AbstractResourceOwner[TestContext, Int] {
override def acquire()(implicit context: TestContext): Resource[Int] =
Resource(Future {
acquired += value
acquired.synchronized {
acquired += value
}
value
})(v =>
Future {
released += v
released.synchronized {
released += v
}
()
}
)
}
Expand Down Expand Up @@ -785,7 +795,9 @@ final class ResourceOwnerSpec extends AsyncWordSpec with Matchers {
override def acquire()(implicit context: TestContext): Resource[Int] = {
Resource(Future(value)) { v =>
Delayed.by((v * 200).milliseconds) {
releaseOrder += v
releaseOrder.synchronized {
releaseOrder += v
}
()
}
}
Expand Down

0 comments on commit d7c60f5

Please sign in to comment.