From 8f80faa23e3ed04844bb5c96e676377e51383ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Galder=20Zamarren=CC=83o?= Date: Thu, 7 Dec 2017 16:23:23 +0100 Subject: [PATCH] HHH-10418 Synchronize on cache instead --- .../cache/infinispan/impl/BaseTransactionalDataRegion.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java index 4c3eb5653b..cd9525bd4b 100644 --- a/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java +++ b/hibernate-infinispan/src/main/java/org/hibernate/cache/infinispan/impl/BaseTransactionalDataRegion.java @@ -144,7 +144,11 @@ public abstract class BaseTransactionalDataRegion assert strategy == Strategy.VALIDATION; return; } - synchronized (this) { + // If two regions share the same name, they should use the same cache. + // Using same cache means they should use the same put validator. + // Besides, any cache interceptor initialization should only be done once. + // Synchronizes on the cache instance since it's shared between regions with same name. + synchronized (cache) { PutFromLoadValidator found = findValidator(cache); validator = found != null ? found : new PutFromLoadValidator(cache, factory); strategy = Strategy.VALIDATION;