commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Atsushi Nakagawa (JIRA)" <>
Subject [jira] [Created] (DBCP-459) InterruptedException consumed and not reset by PoolingDataSource.getConnection()
Date Mon, 11 Apr 2016 04:06:25 GMT
Atsushi Nakagawa created DBCP-459:

             Summary: InterruptedException consumed and not reset by PoolingDataSource.getConnection()
                 Key: DBCP-459
             Project: Commons Dbcp
          Issue Type: Bug
    Affects Versions: 2.1.1
            Reporter: Atsushi Nakagawa
            Priority: Minor

If while `PoolingDataSource.getConnection()` is waiting for an available connection, `Thread.interrupt()`
is called against the current thread, an `java.lang.InterruptedException` is caught internally
but not reset.

It is however thrown out wrapped in an `java.sql.SQLException`.

A stack trace of such an occurrence is as follows:
java.sql.SQLException: Cannot get a connection, general error
	at org.apache.commons.dbcp2.PoolingDataSource.getConnection(
	at org.apache.commons.dbcp2.BasicDataSource.getConnection(
Caused by: java.lang.InterruptedException
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireInterruptibly(
	at java.util.concurrent.locks.ReentrantLock.lockInterruptibly(
	at org.apache.commons.pool2.impl.LinkedBlockingDeque.pollFirst(
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
	at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
	at org.apache.commons.dbcp2.PoolingDataSource.getConnection(
	... 8 more

Since the interrupt status flag is not reset, it is then left to the caller to look out for
it and perform the interrupt specific logic, or reset the flag.  i.e.

try {
} catch (SQLException e) {
    if (e.getCause() instanceof InterruptedException) {

This message was sent by Atlassian JIRA

View raw message