After evicting a region, cache statistics not updated and entities not loaded into cache

Description

A test like this fails:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 public String evictEntityCacheCheck(String CACHE_REGION_NAME){ assertTrue("2lc entity cache is expected to contain Employee id = 20", emf.getCache().contains(Employee.class, 20)); assertTrue("2lc entity cache is expected to contain Employee id = 30", emf.getCache().contains(Employee.class, 30)); // evict entity 2lc emf.getCache().evictAll(); EntityManager em = emf.createEntityManager(); Statistics stats = em.unwrap(Session.class).getSessionFactory().getStatistics(); stats.clear(); SecondLevelCacheStatistics emp2LCStats = stats.getSecondLevelCacheStatistics(CACHE_REGION_NAME+"Employee"); try{ assertEquals("Expected no entities stored in the cache"+emp2LCStats, 0, emp2LCStats.getElementCountInMemory()); assertFalse("2lc entity cache not expected to contain Employee id = 20", emf.getCache().contains(Employee.class, 20)); assertFalse("2lc entity cache not expected to contain Employee id = 30", emf.getCache().contains(Employee.class, 30)); // loading entity stored in previous session, we are expecting miss in 2lc Employee emp = getEmployee(em, 20); assertNotNull("Employee returned", emp); assertEquals("Expected 1 miss in 2LC"+generateEntityCacheStats(emp2LCStats), 1, emp2LCStats.getMissCount()); } finally{ em.close(); } return "OK"; }

Environment

None

Status

Assignee

Galder Zamarreno

Reporter

Galder Zamarreno

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

4.2.6
4.3.0.Beta5

Priority

Major