Re: svn commit: r1305931 - in /tomcat/trunk/modules/jdbc-pool: doc/ src/main/java/org/apache/tomcat/jdbc/pool/ src/main/java/org/apache/tomcat/jdbc/pool/jmx/

2012-03-28 Thread Konstantin Kolinko
2012/3/27  fha...@apache.org:
 Author: fhanik
 Date: Tue Mar 27 17:55:41 2012
 New Revision: 1305931

 URL: http://svn.apache.org/viewvc?rev=1305931view=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=1305931r1=1305930r2=1305931view=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



RE: svn commit: r1305931 - in /tomcat/trunk/modules/jdbc-pool: doc/ src/main/java/org/apache/tomcat/jdbc/pool/ src/main/java/org/apache/tomcat/jdbc/pool/jmx/

2012-03-28 Thread Filip Hanik (mailing lists)
 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();
 }
[Filip Hanik] 
You are correct. I will adjust this.
 
 
 Best regards,
 Konstantin Kolinko
 
 -
 To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
 For additional commands, e-mail: dev-h...@tomcat.apache.org



-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org