You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2014/04/07 19:55:16 UTC

[jira] [Commented] (JCS-115) JDBCDiskCachePoolAccessManager is thread hostile

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

Sebb commented on JCS-115:
--------------------------

There seems no point in creating a singleton class which is then used to invoke the instance method getJDBCDiskCachePoolAccess.
It would be a lot simpler to just have a static method such as

bq. public static JDBCDiskCachePoolAccess getJDBCDiskCachePoolAccess( String poolName, Properties props )


> JDBCDiskCachePoolAccessManager is thread hostile
> ------------------------------------------------
>
>                 Key: JCS-115
>                 URL: https://issues.apache.org/jira/browse/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 instances.
> 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 reference. 
> Another would be to eliminate the props field, adding it as a parameter to methods that need it.
> 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
(v6.2#6252)