GeoTools
  1. GeoTools
  2. GEOT-907

Caching in BufferedAuthorityFactory does not work

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2-RC2
    • Fix Version/s: 2.2.1, 2.3.M0
    • Component/s: referencing
    • Labels:
      None
    • Environment:
      Windows XP SP2, JDK 1.5.0_06, JBoss 4.0.4-GA

      Description

      The problem is one line the this method in
      org.geotools.referencing.factory.BufferedAuthorityFactory:

      private void put(final Object key, final Object object) {
      pool.put(key, object);
      // TODO fixed this line
      int toReplace = maxStrongReferences - pool.size(); // here is the problem
      if (toReplace > 0)

      { ... }

      }

      This line should be
      int toReplace = pool.size() - maxStrongReferences;

      With the current code, if maxStrongReferences = 100 and pool.size() = 20, up to 80 entries in the pool will be overwritten with WeakReferences, resulting in nearly no caching.

      And while you're at it, could you please give
      org.geotools.referencing.factory.epsg.DefaultFactory
      a constructor that lets me set the buffer size in the BufferedAuthorityFactory?

        Issue Links

          Activity

          Hide
          Cory Horner added a comment -
          fixed on 2.2.x @ r20825

          waiting for Martin's feedback before porting to trunk
          Show
          Cory Horner added a comment - fixed on 2.2.x @ r20825 waiting for Martin's feedback before porting to trunk
          Hide
          Cory Horner added a comment -
          i've reverted this change since it caused test failures in other modules and warrants further investigation
          Show
          Cory Horner added a comment - i've reverted this change since it caused test failures in other modules and warrants further investigation
          Hide
          Martin Desruisseaux added a comment -
          Fixed on trunk as of revision 21063. The maven build seems to pass all tests. I didn't changed the 2.2 branch in order to avoid unexpected side-effect in the test suite. Actually the caching was working. This bug had the opposite effect in that the caching was too agressive: strong references were never changed to weak references, resulting in more memory retention than necessary.
          Show
          Martin Desruisseaux added a comment - Fixed on trunk as of revision 21063. The maven build seems to pass all tests. I didn't changed the 2.2 branch in order to avoid unexpected side-effect in the test suite. Actually the caching was working. This bug had the opposite effect in that the caching was too agressive: strong references were never changed to weak references, resulting in more memory retention than necessary.
          Hide
          Martin Desruisseaux added a comment -
          Porting the fix to the 2.2 branch as well.
          Show
          Martin Desruisseaux added a comment - Porting the fix to the 2.2 branch as well.

            People

            • Assignee:
              Martin Desruisseaux
              Reporter:
              Felix Mayer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: