From 977cafca3c4791e7643a6e3eff695f8a980bfbb6 Mon Sep 17 00:00:00 2001 From: Tom Dearman Date: Wed, 24 Jan 2018 10:08:05 +0000 Subject: [PATCH] HHH-12248 Clustered 2nd level cache sometimes throws NullPointerException - rearrange constructor to avoid race condition --- .../cache/infinispan/access/PutFromLoadValidator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/PutFromLoadValidator.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/PutFromLoadValidator.java index 99adda22b861..8ff22469452a 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/PutFromLoadValidator.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/access/PutFromLoadValidator.java @@ -156,6 +156,10 @@ public PutFromLoadValidator(AdvancedCache cache, InfinispanRegionFactory regionF else { throw log.pendingPutsMustHaveMaxIdle(); } + + this.cache = cache; + this.pendingPuts = cacheManager.getCache(pendingPutsName); + CacheMode cacheMode = cache.getCacheConfiguration().clustering().cacheMode(); // Since we need to intercept both invalidations of entries that are in the cache and those // that are not, we need to use custom interceptor, not listeners (which fire only for present entries). @@ -166,9 +170,6 @@ public PutFromLoadValidator(AdvancedCache cache, InfinispanRegionFactory regionF } addToCache(cache, this); } - - this.cache = cache; - this.pendingPuts = cacheManager.getCache(pendingPutsName); } /**