Fixes #1060 Support experimental throw-if-suspended functionality.

pull/1074/head
Brett Wooldridge 7 years ago
parent 7302390bf7
commit 1f73e9a005

@ -16,6 +16,8 @@
package com.zaxxer.hikari.util;
import java.sql.SQLException;
import java.sql.SQLTransientException;
import java.util.concurrent.Semaphore;
/**
@ -33,7 +35,7 @@ public class SuspendResumeLock
@Override
public void release() {}
@Override
public void suspend() {}
@ -57,8 +59,12 @@ public class SuspendResumeLock
acquisitionSemaphore = (createSemaphore ? new Semaphore(MAX_PERMITS, true) : null);
}
public void acquire()
public void acquire() throws SQLException
{
if (Boolean.getBoolean("com.zaxxer.hikari.throwIfSuspended")) {
throw new SQLTransientException("The pool is currently suspended and configured to throw exceptions upon acquisition");
}
acquisitionSemaphore.acquireUninterruptibly();
}

Loading…
Cancel
Save