1 Reply Latest reply on Dec 18, 2005 10:47 PM by ben.wang

    Wrong region selected in RegionManager

    crl42

      In RegionManager the wrong region is selected for a fqn because of the use of an HashMap to store the configurated region elements from definition

      Since I need this correction now, I submited a bug on jira and I proposed a patch

      http://jira.jboss.com/jira/browse/JBCACHE-373

      Patch:

      --- RegionManager.java.orig 2005-12-15 13:21:32.014766898 +0100
      +++ RegionManager.java 2005-12-15 14:14:12.752630015 +0100
      @@ -11,7 +11,7 @@
      import org.apache.commons.logging.LogFactory;
      import org.jboss.cache.TreeCache;

      -import java.util.HashMap;
      +import java.util.LinkedHashMap;
      import java.util.Map;

      /**
      @@ -28,7 +28,7 @@
      private Log log_=LogFactory.getLog(RegionManager.class);
      // TODO We should externalize this.
      public final static int CAPACITY = 200000;
      - private Map regionMap_ = new HashMap();
      + private Map regionMap_ = new LinkedHashMap();
      // optimization
      private Region[] regions_;
      private EvictionPolicy policy_;
      @@ -95,8 +95,8 @@
      String myRFqn = appendFqn(myFqn);
      // TODO need further optimization in regex matching

      - // Do it in reverse order such that children fqn gets matched first.
      - for (int i = (regions.length - 1); i >= 0; i--)
      + // Do it in direct order such that children fqn gets matched first.
      + for (int i = 0; i<regions.length ; i++)
      {
      String fqn = regions.getFqn();
      if (myRFqn.startsWith(fqn)) return regions
      ;

      I hope this help.

      Carlo Rossi