Permalink
Browse files

use ensure to make sure connection is added back, fix MatchError

  • Loading branch information...
1 parent 7e1cb6d commit 1bdff2d3b6764dbf90d8b70e129b4a7dbda972dd @freels freels committed Nov 11, 2011
View
14 querulous-core/src/main/scala/com/twitter/querulous/async/BlockingDatabaseWrapper.scala
@@ -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)
}
}
}
@@ -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()
+ }
}
}

0 comments on commit 1bdff2d

Please sign in to comment.