2015-07-21 21:09 GMT+09:00 Konstantin Kolinko <knst.koli...@gmail.com>:

> 2015-07-21 10:01 GMT+03:00  <kfuj...@apache.org>:
> > Author: kfujino
> > Date: Tue Jul 21 07:01:44 2015
> > New Revision: 1692057
> >
> > URL: http://svn.apache.org/r1692057
> > Log:
> > Fix potential NPE in QueryTimeoutInterceptor.
> >
> > Modified:
> >
>  
> tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java
> >     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
> >
> > Modified:
> tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java
> > URL:
> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java?rev=1692057&r1=1692056&r2=1692057&view=diff
> >
> ==============================================================================
> > ---
> tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java
> (original)
> > +++
> tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/QueryTimeoutInterceptor.java
> Tue Jul 21 07:01:44 2015
> > @@ -28,12 +28,13 @@ import org.apache.tomcat.jdbc.pool.PoolP
> >
> >  public class QueryTimeoutInterceptor extends
> AbstractCreateStatementInterceptor {
> >      private static Log log =
> LogFactory.getLog(QueryTimeoutInterceptor.class);
> > -    int timeout;
> > +    int timeout = 1;
> >
> >      @Override
> >      public void setProperties(Map<String,InterceptorProperty>
> properties) {
> >          super.setProperties(properties);
> > -        timeout = properties.get("queryTimeout").getValueAsInt(-1);
> > +        InterceptorProperty p = properties.get("queryTimeout");
> > +        if (p!=null) timeout = p.getValueAsInt(timeout);
>
> Old code has default value of "-1". The new code has default value of "+1".
>  <dev-h...@tomcat.apache.org>
>


Thanks for the comment.

Actually, the old code did not work correctly.
If queryTimeout has not been set, the old code threw NullpointerException
instead of returning -1.
So I fixed this potential NPE and aligned the behavior with the document.



> --
> Keiichi.Fujino
>  <dev-h...@tomcat.apache.org>
>  <dev-h...@tomcat.apache.org>
>

Reply via email to