You can't use

  finally {
    db.close();
  }

here because that would decrement the close count no matter what, and then return to the caller a handle which would later be decremented a second time when the request completes.  Bad.

No, here we only want to decrement the close when we aren't going to complete normally, but have already incremented the open counter.