db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/cache LocalCache.java
Date Mon, 20 Sep 2004 16:13:36 GMT
arminw      2004/09/20 09:13:36

  Modified:    src/java/org/apache/ojb/broker/cache LocalCache.java
  Log:
  introduce an check in LocalCache#lookup method which test if the top-level is same
  or super class of found object class. This helps to avoid wrong result when an
  Identity-collision (same two different objects have the same Identity hashCode) happens.
  
  Revision  Changes    Path
  1.3       +20 -2     db-ojb/src/java/org/apache/ojb/broker/cache/LocalCache.java
  
  Index: LocalCache.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/cache/LocalCache.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalCache.java	18 Sep 2004 17:34:06 -0000	1.2
  +++ LocalCache.java	20 Sep 2004 16:13:36 -0000	1.3
  @@ -217,7 +217,25 @@
               // 2. get CacheStrategy and lokup in real cache
               CacheStrategy realCache = getCacheStrategy(oid);
               result = realCache.lookup(broker, oid);
  -            // 3. if we have a match and local cache is enabled
  +            // 3. check for Identity/Object collision
  +            if (result != null && !oid.getObjectsTopLevelClass().isAssignableFrom(result.getClass()))
  +            {
  +                log.warn("Wrong key/object pair found in cache, Identity is " + oid + ",
associate object is "
  +                        + result + ". Could be an Identity/Object-collision, will skip
this result.");
  +                if(log.isDebugEnabled())
  +                {
  +                    try
  +                    {
  +                        throw new Exception();
  +                    }
  +                    catch(Exception e)
  +                    {
  +                        e.printStackTrace();
  +                    }
  +                }
  +                result = null;
  +            }
  +            // 4. if we have a match and local cache is enabled
               // put object in local cache
               if (result != null && (enabledReadCache || broker.isInTransaction()))
               {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message