commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] [Created] (JCS-115) JDBCDiskCachePoolAccessManager is thread hostile
Date Mon, 07 Apr 2014 10:39:15 GMT
Sebb created JCS-115:

             Summary: JDBCDiskCachePoolAccessManager is thread hostile
                 Key: JCS-115
             Project: Commons JCS
          Issue Type: Bug
            Reporter: Sebb
            Priority: Critical

JDBCDiskCachePoolAccessManager is currently designed as a singleton.

However, it contains a mutable field, props, with a protected setter.

This just does not work in a multi-threaded environment.

It looks like the reason for the singleton is to share a the HashMap of JDBCDiskCachePoolAccess

So one possible fix would be to make the HashMap static instead of using a singleton, replace
getInstance with a public constructor.
AFAICT this won't affect garbage collection of the pool as there is no way to clear the singleton

Another would be to eliminate the props field, adding it as a parameter to methods that need

It looks as though the props field is only used when creating the entry for the map, so it
should be supplied at the same time as the pool name. It does not appear to be possible to
delete a pool entry once created, so a given set of props can only be used once to create
a pool of a given name.

In any case, the setter for props should be removed and the field should be made final (if
it is kept).

Note: this was found when investigating JCS-114 - one of the tests fails to invoke JDBCDiskCachePoolAccessManager.setProps

This message was sent by Atlassian JIRA

View raw message