Uploaded image for project: 'Commons JCS'
  1. Commons JCS
  2. JCS-115

JDBCDiskCachePoolAccessManager is thread hostile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • jcs-2.0-beta-1
    • None
    • None

    Description

      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

      Attachments

        Issue Links

          Activity

            People

              tv Thomas Vandahl
              sebb Sebb
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: