2012/3/27 :
> Author: fhanik
> Date: Tue Mar 27 17:55:41 2012
> New Revision: 1305931
>
> URL: http://svn.apache.org/viewvc?rev=1305931&view=rev
> Log:
> https://issues.apache.org/bugzilla/show_bug.cgi?id=52066
> Add in a configuration attribute to allow a thread interrupt state to be
> retained for the calling library to see
>
>
> Modified:
> tomcat/trunk/modules/jdbc-pool/doc/jdbc-pool.xml
>
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
>
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
>
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java
>
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
>
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
>
> Modified:
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
> URL:
> http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?rev=1305931&r1=1305930&r2=1305931&view=diff
> ==
> ---
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
> (original)
> +++
> tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
> Tue Mar 27 17:55:41 2012
> @@ -381,7 +381,9 @@ public class ConnectionPool {
> }
> } //while
> } catch (InterruptedException ex) {
> - Thread.interrupted();
> + if (!getPoolProperties().getPropagateInterruptState()) {
> + Thread.interrupted();
> + }
> }
> if (pool.size()==0 && force && pool!=busy) pool = busy;
> }
> @@ -626,7 +628,9 @@ public class ConnectionPool {
> //retrieve an existing connection
> con = idle.poll(timetowait, TimeUnit.MILLISECONDS);
> } catch (InterruptedException ex) {
> - Thread.interrupted();//clear the flag, and bail out
> + if (!getPoolProperties().getPropagateInterruptState()) {
> + Thread.interrupted();
> + }
> SQLException sx = new SQLException("Pool wait interrupted.");
> sx.initCause(ex);
> throw sx;
>
If InterruptedException was thrown by JRE it alone means that
interrupted flag has been cleared. So Thread.interrupted() call is a
NOOP.
(Effectively the interruption state means "to interrupt the next
wait() etc. call immediately when they are called". When the actual
interruption happens the exception is created and the flag is
cleared.)
To propagate the interruption state the code would be
if (propagate) {
Thread.currentThread().interrupt();
}
Best regards,
Konstantin Kolinko
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org