diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java index a5884d0b34bef8bd61eb372b635d3c1b8af0bb85..233eab2adc78c0877d1886d88f98e4ef974408ee 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicCache.java @@ -126,7 +126,11 @@ public class NeatLogicCache implements Cache { if (value instanceof List && ((List) value).isEmpty()) { return; } - getCache().put(key, value); + if (!this.readOnly) { + getCache().put(key, CacheUtils.deepCopy(value)); + } else { + getCache().put(key, value); + } } @Override @@ -162,4 +166,4 @@ public class NeatLogicCache implements Cache { public String toString() { return "Ehcache3 {" + id + "}"; } -} \ No newline at end of file +} diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java index e9826018e1507b1ea908e38c09c56d3213986a85..e51fb36578d83d66d1845f938601cc66146ee3f4 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java @@ -183,7 +183,11 @@ public class NeatLogicConcurrentSafeCache implements Cache { @Override public void putObject(Object key, Object value) { if (value != null) { - getCache().put(key, value); + if (!this.readOnly) { + getCache().put(key, CacheUtils.deepCopy(value)); + } else { + getCache().put(key, value); + } } String lockKey = generateLockKey(getId(), key); ReentrantLock lock = LOCAL_LOCK_MAP.get(lockKey);