Describe the bug
There is an issue with Switcher Response caching mechanism when using async settings, e.g. throttling or silent mode where response calls are incorrectly updated when inputs are updated in runtime. This issue happens because of a reference object that is changing the cache key, which invalidates the result.
To Reproduce
Update strategy inputs using a pre-configured Switcher:
static void main() {
var feature = getSwitcher(MY_SWITCHER)
.throttle(1000);
var random = new Random();
scheduler.scheduleAtFixedRate(() -> {
var input = "user_1";
if (random.nextInt() % 2 == 0) {
input = "user_0";
}
long start = System.currentTimeMillis();
logger.info("Switcher {} is {} for {} ({}ms)", MY_SWITCHER, feature.checkValue(input).isItOn(), input,
System.currentTimeMillis() - start);
}, 0, 1, TimeUnit.SECONDS);
}
Expected behavior
Cache cannot use response reference thus values retrieved from it should not change if strategy inputs are modified in runtime.
Work-around
Use getSwitcher if strategy inputs are volatile.
getSwitcher(MY_SWITCHER)
.throttle(1000)
.checkValue(input)
.isItOn()
Describe the bug
There is an issue with Switcher Response caching mechanism when using async settings, e.g. throttling or silent mode where response calls are incorrectly updated when inputs are updated in runtime. This issue happens because of a reference object that is changing the cache key, which invalidates the result.
To Reproduce
Update strategy inputs using a pre-configured Switcher:
Expected behavior
Cache cannot use response reference thus values retrieved from it should not change if strategy inputs are modified in runtime.
Work-around
Use getSwitcher if strategy inputs are volatile.