Skip to content

Commit 57efc48

Browse files
committed
Merge branch 'ExceptionMessaging'
2 parents c4707d3 + 8e5de43 commit 57efc48

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/com/mongodb/DBPortPool.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,13 @@ public static class NoMoreConnection extends MongoInternalException {
146146

147147
public static class SemaphoresOut extends NoMoreConnection {
148148
private static final long serialVersionUID = -4415279469780082174L;
149+
private static final String message = "Concurrent requests for database connection have exceeded limit";
149150
SemaphoresOut(){
150-
super( "Out of semaphores to get db connection" );
151+
super( message );
152+
}
153+
154+
SemaphoresOut(int numPermits){
155+
super( message + " of " + numPermits);
151156
}
152157
}
153158

@@ -190,7 +195,7 @@ protected int pick( int recommended, boolean couldCreate ){
190195
public DBPort get() {
191196
DBPort port = null;
192197
if ( ! _waitingSem.tryAcquire() )
193-
throw new SemaphoresOut();
198+
throw new SemaphoresOut(_waitingSem.availablePermits() );
194199

195200
try {
196201
port = get( _options.maxWaitTime );

0 commit comments

Comments
 (0)