File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
ebean-datasource/src/main/java/io/ebean/datasource/pool Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 120120 */
121121final class ConnectionBuffer {
122122
123+ static final Object POP_LAST = new Object ();
124+
123125 private final Node free = Node .init ();
124126 private final Node freeEnd = free .next ;
125127 private final Node busy = Node .init ();
@@ -218,13 +220,14 @@ PooledConnection popFree(Object affinityId) {
218220 Node node ;
219221 if (affinityId == null || affinityNodes == null ) {
220222 node = free .next ;
223+ } else if (affinityId == POP_LAST ) {
224+ node = freeEnd .prev ;
221225 } else {
222226 node = affinityNodes [affinityId .hashCode () % hashSize ].find (affinityId );
223227 if (node == null ) {
224- // when we did not find a node with that affinity, we take the last (oldest one)
225- // and reuse this with the new affinity. This avoids to "steal" the affinity
226- // from the newest one.
227- node = freeEnd .prev ;
228+ // when we did not find a node with that affinity, we return null
229+ // this allows the pool to grow to its maximum size
230+ return null ;
228231 }
229232 }
230233 if (node .isBoundaryNode ()) {
Original file line number Diff line number Diff line change @@ -231,13 +231,19 @@ private PooledConnection _obtainConnection(Object affinitiyId) throws Interrupte
231231 if (connection != null ) {
232232 return connection ;
233233 }
234+ if (affinitiyId != null ) {
235+ connection = extractFromFreeList (ConnectionBuffer .POP_LAST );
236+ if (connection != null ) {
237+ return connection ;
238+ }
239+ }
234240 }
235241 try {
236242 // The pool is at maximum size. We are going to go into
237243 // a wait loop until connections are returned into the pool.
238244 waitCount ++;
239245 waitingThreads ++;
240- return _obtainConnectionWaitLoop (affinitiyId );
246+ return _obtainConnectionWaitLoop (null );
241247 } finally {
242248 waitingThreads --;
243249 }
You can’t perform that action at this time.
0 commit comments