99 * A buffer especially designed for Busy PooledConnections.
1010 * <p>
1111 * All thread safety controlled externally (by PooledConnectionQueue).
12- * </p>
1312 * <p>
1413 * It has a set of 'slots' and PooledConnections know which slot they went into
1514 * and this allows for fast addition and removal (by slotId without looping).
1615 * The capacity will increase on demand by the 'growBy' amount.
17- * </p>
18- *
19- * @author rbygrave
2016 */
2117class BusyConnectionBuffer {
2218
@@ -82,7 +78,6 @@ protected int add(PooledConnection pc) {
8278 }
8379
8480 boolean remove (PooledConnection pc ) {
85-
8681 int slotId = pc .getSlotId ();
8782 if (slots [slotId ] != pc ) {
8883 PooledConnection heldBy = slots [slotId ];
@@ -98,7 +93,6 @@ boolean remove(PooledConnection pc) {
9893 * Collect the load statistics from all the busy connections.
9994 */
10095 void collectStatistics (PooledConnectionStatistics .LoadValues values , boolean reset ) {
101-
10296 for (PooledConnection slot : slots ) {
10397 if (slot != null ) {
10498 values .plus (slot .getStatistics ().getValues (reset ));
@@ -134,14 +128,11 @@ void closeBusyConnections(long leakTimeMinutes) {
134128
135129 private void closeBusyConnection (PooledConnection pc ) {
136130 try {
137-
138131 logger .warn ("DataSourcePool closing busy connection? " + pc .getFullDescription ());
139132 System .out .println ("CLOSING busy connection: " + pc .getFullDescription ());
140133
141134 pc .closeConnectionFully (false );
142-
143135 } catch (Exception ex ) {
144- // this should never actually happen
145136 logger .error ("Error when closing potentially leaked connection " + pc .getDescription (), ex );
146137 }
147138 }
@@ -150,13 +141,11 @@ private void closeBusyConnection(PooledConnection pc) {
150141 * Returns information describing connections that are currently being used.
151142 */
152143 String getBusyConnectionInformation (boolean toLogger ) {
153-
154144 if (toLogger ) {
155145 logger .info ("Dumping [{}] busy connections: (Use datasource.xxx.capturestacktrace=true ... to get stackTraces)" , size ());
156146 }
157147
158148 StringBuilder sb = new StringBuilder ();
159-
160149 for (PooledConnection pc : slots ) {
161150 if (pc != null ) {
162151 if (toLogger ) {
@@ -175,7 +164,6 @@ String getBusyConnectionInformation(boolean toLogger) {
175164 * Return the position of the next empty slot.
176165 */
177166 private int nextEmptySlot () {
178-
179167 // search forward
180168 while (++pos < slots .length ) {
181169 if (slots [pos ] == null ) {
@@ -189,7 +177,6 @@ private int nextEmptySlot() {
189177 return pos ;
190178 }
191179 }
192-
193180 // not expecting this
194181 throw new RuntimeException ("No Empty Slot Found?" );
195182 }
0 commit comments