commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] [Commented] (JCS-113) Potential NPE in JDBCDiskCache
Date Thu, 03 Apr 2014 22:43:15 GMT


Sebb commented on JCS-113:

Partial fix. Does not address the basic issue but at least allows debugging without causing
an NPE.

JCS-113 Potential NPE in JDBCDiskCache
Fixed NPEs in getSize() and getStatistics()


> Potential NPE in JDBCDiskCache
> ------------------------------
>                 Key: JCS-113
>                 URL:
>             Project: Commons JCS
>          Issue Type: Bug
>            Reporter: Sebb
> The test JDBCDiskCacheManagerUnitTest fails with an NPE if debug logging is enabled.
> {code}
> java.lang.NullPointerException
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCache.getSize(
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCache.getStatistics(
> at org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache.getStats(
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCache.toString(
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManagerAbstractTemplate.getCache(
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManager.getCache(
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManagerUnitTest.testGetCache_normal(
> {code}
> That happens because the getSize() method calls
> {code}
> getPoolAccess().getConnection()
> {code}
> and getPoolAccess() may return null if the initializePoolAccess method called by the
constructor fails to set up the pool.
> It is trivial to check if the poolAccess field has been set up and avoid the NPE in getSize().
However, the getPoolAccess() method is used extensively within the class, and also externally
as well.
> It looks as though the class is barely usable if the field cannot be initialised, so
it might perhaps be better if the constructor threw an Exception of some kind.

This message was sent by Atlassian JIRA

View raw message