#1587 - Fix for propagation of @Cache(nearCache=true)

This commit is contained in:
rob bygrave
2018-12-21 02:19:21 +13:00
parent 0377e3ec5c
commit 81f42f8e95
3 changed files with 40 additions and 1 deletions
+9
View File
@@ -79,6 +79,15 @@ public class ServerCacheOptions {
copy.maxIdleSecs = maxIdleSecs;
copy.maxSecsToLive = maxSecsToLive;
copy.trimFrequency = trimFrequency;
copy.nearCache = this.nearCache;
return copy;
}
/**
* Return a copy of this object with nearCache option.
*/
public ServerCacheOptions copy(boolean nearCache) {
ServerCacheOptions copy = copy();
copy.nearCache = nearCache;
return copy;
}
@@ -132,7 +132,7 @@ class DefaultCacheHolder {
if (tuning != null) {
return new ServerCacheOptions(nearCache, tuning).applyDefaults(beanDefault);
}
return beanDefault.copy();
return beanDefault.copy(nearCache);
}
}
@@ -0,0 +1,30 @@
package io.ebean.cache;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class ServerCacheOptionsTest {
@Test
public void copy_when_off() {
ServerCacheOptions basic = new ServerCacheOptions();
assertThat(basic.isNearCache()).isFalse();
ServerCacheOptions copy = basic.copy(true);
assertThat(copy.isNearCache()).isTrue();
}
@Test
public void copy_when_on() {
ServerCacheOptions basic = new ServerCacheOptions();
basic.setNearCache(true);
assertThat(basic.isNearCache()).isTrue();
ServerCacheOptions copy = basic.copy(false);
assertThat(copy.isNearCache()).isFalse();
}
}