Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-5936

Mock Object implementation causes three hibernate int test cases regression

    XMLWordPrintable

Details

    • Not Required

    Description

      org.jboss.test.hibernate.test.HibernateConfigurationUnitTestCase fails with the new released hibernate core 3.3.2.GA_CP04

      java.lang.NullPointerException
      at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:882)
      at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:384)
      at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1340)
      at org.jboss.hibernate.jmx.Hibernate.buildSessionFactory(Hibernate.java:320)
      at org.jboss.hibernate.jmx.Hibernate.start(Hibernate.java:274)

      this is caused by an improvement I made in the SessionFactoryImpl.allCacheRegions, it was HashMap, and I changed it to ConcurrentHashMap to get better performance.

      one difference between these two Map implementation is HashMap allows Null key but Concurrent throws NPE if the key is null.

      and in the test org.jboss.test.hibernate.test.HibernateConfigurationUnitTestCase, it uses org.jboss.test.hibernate.mocks.MockRegion when initialize SessionFactory, and org.jboss.test.hibernate.mocks.MockRegion.getName() returns null.
      so, if the query cache enabled, the test throws NPE due to ConcurrentHashMap does not allow NULL key

      from SessionFactoryImpl
      allCacheRegions.put( updateTimestampsCache.getRegion().getName(), updateTimestampsCache.getRegion() );

      NOTE: in real, hibernate will not build a cache region with a null name, so this bug only relates to the test, i will update MockRegion to give a region name.

      Attachments

        Issue Links

          Activity

            People

              shaozliu Strong Liu(刘少壮) (Inactive)
              shaozliu Strong Liu(刘少壮) (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: