Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
use ensure to make sure connection is added back, fix MatchError
Browse files Browse the repository at this point in the history
  • Loading branch information
freels committed Nov 11, 2011
1 parent 7e1cb6d commit 1bdff2d
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -46,11 +46,9 @@ extends AsyncDatabase {
def withConnection[R](f: Connection => R) = {
checkoutConnection() flatMap { conn =>
workPool {
try {
f(conn)
} finally {
database.close(conn)
}
f(conn)
} ensure {
database.close(conn)
}
}
}
Expand All @@ -66,8 +64,10 @@ extends AsyncDatabase {
}

// cancel future if it times out
result.within(checkoutTimer, openTimeout) onFailure {
case _: java.util.concurrent.TimeoutException => result.cancel()
result.within(checkoutTimer, openTimeout) onFailure { e =>
if (e.isInstanceOf[java.util.concurrent.TimeoutException]) {
result.cancel()
}
}
}

Expand Down

0 comments on commit 1bdff2d

Please sign in to comment.