Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit b1a2f4b

Browse files
h2002044arindam-bandyopadhyay
authored andcommitted
Fixes #21355: Race condition in ConnectionPool (connectors-runtime) (#22086)
1 parent a0398ec commit b1a2f4b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/ConnectionPool.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,13 @@ public ResourceHandle getResource(ResourceSpec spec, ResourceAllocator alloc, Tr
422422

423423
if (!blocked) {
424424
//add to wait-queue
425-
Object waitMonitor = waitQueue.addToQueue();
425+
Object waitMonitor = new Object();
426426
if (poolLifeCycleListener != null) {
427427
poolLifeCycleListener.connectionRequestQueued();
428428
}
429429
synchronized (waitMonitor) {
430+
waitQueue.addToQueue(waitMonitor);
431+
430432
try {
431433
logFine("Resource Pool: getting on wait queue");
432434
waitMonitor.wait(remainingWaitTime);
@@ -450,8 +452,9 @@ public ResourceHandle getResource(ResourceSpec spec, ResourceAllocator alloc, Tr
450452
}
451453
} else {
452454
//add to reconfig-wait-queue
453-
Object reconfigWaitMonitor = reconfigWaitQueue.addToQueue();
455+
Object reconfigWaitMonitor = new Object();
454456
synchronized (reconfigWaitMonitor) {
457+
reconfigWaitQueue.addToQueue(reconfigWaitMonitor);
455458
try {
456459
if(reconfigWaitTime > 0){
457460
if(_logger.isLoggable(Level.FINEST)) {

appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/waitqueue/DefaultPoolWaitQueue.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,9 @@ public synchronized int getQueueLength() {
7070
return list.size();
7171
}
7272

73-
public synchronized Object addToQueue() {
73+
public synchronized void addToQueue(Object waitMonitor) {
7474

75-
Object waitMonitor = new Object();
7675
list.addLast(waitMonitor);
77-
return waitMonitor;
7876
}
7977

8078
public synchronized boolean removeFromQueue(Object o) {

appserver/connectors/connectors-runtime/src/main/java/com/sun/enterprise/resource/pool/waitqueue/PoolWaitQueue.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ public interface PoolWaitQueue {
6161
/**
6262
* resource requesting thread will be added to queue<br>
6363
* and the object on which it is made to wait is returned
64-
* @return Object
64+
* @param o Object
6565
*/
66-
Object addToQueue();
66+
void addToQueue(Object o);
6767

6868
/**
6969
* removes the specified object (resource request) from the queue

0 commit comments

Comments
 (0)