datastax/java-driver — pull request #190 by olim7t (2014-06-27 14:44:33+00:00)
Title: Fix negative HostConnectionPool open count (JAVA-349).

The issue was in `doTrashCondition`: `connections.remove` could return `false` (because the connection had already been trashed while being returned by another client), but we would still decrement `open`.

I've returned a boolean to fix the counter after the fact. This still leaves a window of vulnerability where `open` is underestimated by one. This could lead to creating MAX + 1 connections, which is not great but tolerable IMO.

To shorten that window, I've also slightly changed `returnConnection` so that we don't try to replace or trash a connection that's already trashed.