commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hudson (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JCS-113) Potential NPE in JDBCDiskCache
Date Fri, 06 Jun 2014 15:30:02 GMT

    [ https://issues.apache.org/jira/browse/JCS-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14019925#comment-14019925
] 

Hudson commented on JCS-113:
----------------------------

UNSTABLE: Integrated in commons-jcs #19 (See [https://builds.apache.org/job/commons-jcs/19/])
Fix JCS-113: Improve error handling by bubbling up exceptions. Simplify code. (tv: rev e25521c7482657965447c373ef2d9f966e79c8e8)
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessManager.java
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManager.java
* commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheManager.java
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccessFactory.java
* src/changes/changes.xml
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCachePoolAccess.java
* commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLTableOptimizerManualTester.java
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCache.java
* commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheManagerAbstractTemplate.java


> Potential NPE in JDBCDiskCache
> ------------------------------
>
>                 Key: JCS-113
>                 URL: https://issues.apache.org/jira/browse/JCS-113
>             Project: Commons JCS
>          Issue Type: Bug
>            Reporter: Sebb
>            Assignee: Thomas Vandahl
>             Fix For: jcs-2.0.0
>
>
> 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(JDBCDiskCache.java:982)
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCache.getStatistics(JDBCDiskCache.java:1146)
> at org.apache.commons.jcs.auxiliary.disk.AbstractDiskCache.getStats(AbstractDiskCache.java:525)
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCache.toString(JDBCDiskCache.java:1251)
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManagerAbstractTemplate.getCache(JDBCDiskCacheManagerAbstractTemplate.java:119)
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManager.getCache(JDBCDiskCacheManager.java:117)
> at org.apache.commons.jcs.auxiliary.disk.jdbc.JDBCDiskCacheManagerUnitTest.testGetCache_normal(JDBCDiskCacheManagerUnitTest.java:49)
> {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
(v6.2#6252)

Mime
View raw message