3 Replies Latest reply on Oct 24, 2008 12:58 PM by Elias Ross

    Found Bug with Hibernate, TreeCache and Cacheloader, if pass

    Holger Niessen Newbie

      First: Sorry for my english ;)

      Environment:
      JBoss 4.3.0 EAP
      TreeCache 1.4.1 SP8 and SP10
      Hibernate 3.2


      If i use an CacheLoader (in my use case the FileCacheLoader) and locking is PESSIMISTIC and passivation is set to false,
      the FileCacheloader doesn't store anything. Only if i change to passivation true or is user locking OPTIMISTIC.

      The Problem/Bug is clear and found in the CacheStoreInterceptor. If PESSIMISTIC locking is configured,
      Hibernate use cache.putfailfast. In this case, the MethodId in CacheStoreInterceptor is 4 (MethodDeclarations.putFailFastKeyValueMethodLocal).
      But this isn't handle in the CacheStoreInterceptor, so no CacheLoader is called.

      Original Code:

       switch (m.getMethodId())
       {
       case MethodDeclarations.putDataMethodLocal_id:
       case MethodDeclarations.putDataEraseMethodLocal_id:
       Modification mod = convertMethodCallToModification(m);
       log.debug(mod);
       fqn = mod.getFqn();
      
       loader.put(Collections.singletonList(mod));
       if (cache.getUseInterceptorMbeans()&& statsEnabled)
       m_cacheStores++;
       break;
       case MethodDeclarations.putKeyValMethodLocal_id:
       fqn=(Fqn)args[1];
       key=args[2];
       value=args[3];
       tmp_retval = loader.put(fqn, key, value);
       use_tmp_retval = true;
       if (cache.getUseInterceptorMbeans()&& statsEnabled)
       m_cacheStores++;
       break;
       }
      


      Worked Code:
       switch (m.getMethodId())
       {
       case MethodDeclarations.putDataMethodLocal_id:
       case MethodDeclarations.putDataEraseMethodLocal_id:
       Modification mod = convertMethodCallToModification(m);
       log.debug(mod);
       fqn = mod.getFqn();
      
       loader.put(Collections.singletonList(mod));
       if (cache.getUseInterceptorMbeans()&& statsEnabled)
       m_cacheStores++;
       break;
       case MethodDeclarations.putKeyValMethodLocal_id:
       case MethodDeclarations.putFailFastKeyValueMethodLocal:
       fqn=(Fqn)args[1];
       key=args[2];
       value=args[3];
       tmp_retval = loader.put(fqn, key, value);
       use_tmp_retval = true;
       if (cache.getUseInterceptorMbeans()&& statsEnabled)
       m_cacheStores++;
       break;
       }
      


      Regards, Holger