You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2014/04/04 00:39:03 UTC
svn commit: r1584437 - in /commons/proper/jcs/trunk/src: changes/changes.xml
java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
Author: sebb
Date: Thu Apr 3 22:39:03 2014
New Revision: 1584437
URL: http://svn.apache.org/r1584437
Log:
JCS-113 Potential NPE in JDBCDiskCache
Fixed NPEs in getSize() and getStatistics()
Modified:
commons/proper/jcs/trunk/src/changes/changes.xml
commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
Modified: commons/proper/jcs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/changes/changes.xml?rev=1584437&r1=1584436&r2=1584437&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/changes/changes.xml (original)
+++ commons/proper/jcs/trunk/src/changes/changes.xml Thu Apr 3 22:39:03 2014
@@ -20,6 +20,10 @@
</properties>
<body>
<release version="2.0" date="unreleased" description="JDK 1.6 based major release">
+ <action issue="JCS-113" dev="sebb" type="fix">
+ Potential NPE in JDBCDiskCache
+ Fixed NPEs in getSize() and getStatistics()
+ </action>
<action issue="JCS-112" dev="sebb" type="fix">
RemoteCacheServer.logUpdateInfo bug updating put count
</action>
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java?rev=1584437&r1=1584436&r2=1584437&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java Thu Apr 3 22:39:03 2014
@@ -976,10 +976,14 @@ public class JDBCDiskCache<K extends Ser
String selectString = "select count(*) from " + getJdbcDiskCacheAttributes().getTableName()
+ " where REGION = ?";
+ final JDBCDiskCachePoolAccess pool = getPoolAccess();
+ if (pool == null) {
+ return size;
+ }
Connection con;
try
{
- con = getPoolAccess().getConnection();
+ con = pool.getConnection();
}
catch ( SQLException e1 )
{
@@ -1141,26 +1145,40 @@ public class JDBCDiskCache<K extends Ser
se.setData( "" + getMatchingCount );
elems.add( se );
+ final JDBCDiskCachePoolAccess pool = getPoolAccess();
+
se = new StatElement();
se.setName( "Size" );
- se.setData( "" + getSize() );
+ if (pool != null) {
+ se.setData( "" + getSize() );
+ } else {
+ se.setData( "No db connection pool found" );
+ }
elems.add( se );
se = new StatElement();
se.setName( "Active DB Connections" );
- se.setData( "" + getPoolAccess().getNumActiveInPool() );
+ if (pool != null) {
+ se.setData( "" + pool.getNumActiveInPool() );
+ } else {
+ se.setData( "No db connection pool found" );
+ }
elems.add( se );
se = new StatElement();
se.setName( "Idle DB Connections" );
- se.setData( "" + getPoolAccess().getNumIdleInPool() );
+ if (pool != null) {
+ se.setData( "" + pool.getNumIdleInPool() );
+ } else {
+ se.setData( "No db connection pool found" );
+ }
elems.add( se );
se = new StatElement();
se.setName( "DB URL" );
- if ( getPoolAccess() != null )
+ if ( pool != null )
{
- se.setData( "" + getPoolAccess().getPoolUrl() );
+ se.setData( "" + pool.getPoolUrl() );
}
else
{