Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JCache: hit and miss counter fail TCK tests for noop EntryProcessor operations #132

cruftex opened this issue Sep 10, 2019 · 0 comments


Copy link

cruftex commented Sep 10, 2019

With version 1.4 no hit or miss is counted, for a no operation EntryProcessor. This is a violation of the (current) JCache TCK, however, in our opinion it is correct, since with 1.4 the entry is never touched. Details:

The JCache TCK makes assumptions about the Hit and Miss statistics counters when an entry processor is used. The underlying assumption is, that a cached entry is always accessed.

The comment in the TCK reads:

The lookup and locking of the key is enough to invoke the hit or miss. No
Cache.Entry or MutableEntry operation is required.

The relevant TCK tests are:

  • CacheMBStatisticsBeanTest.testCacheStatisticsInvokeEntryProcessorNoOp()
  • CacheMBStatisticsBeanTest.testCacheStatisticsInvokeEntryProcessorGet()
  • CacheMBStatisticsBeanTest.testCacheStatisticsInvokeEntryProcessorUpdate()

For example the sequence:

    // increase put counter
    cache.put(1l, "Sooty");

    //existent key. increase hit counter even though this entry processor does not call anything
    cache.invoke(1l, new NoOpEntryProcessor<Long, String>());
    cache.invoke(1l, new NoOpEntryProcessor<Long, String>());

    //non-existent key. increase miss counter
    cache.invoke(1000l, new NoOpEntryProcessor<Long, String>());

Starting in version 1.4 cache2k will not access the cache content, when no operation is done or it is only a write operation. With this optimization there is actually no way to find out whether its a hit or a miss, hence, there is no way to update the counters accordingly.

This optimization is IMHO legal with respect to the specification. The JCache TCK is asserting a behavior that is not specified. The Spec says the contrary (EntryProcessor javadoc):

Implementations may execute {@link EntryProcessor}s in situ, thus avoiding
locking, round-trips and expensive network transfers.

@cruftex cruftex changed the title JCache: hit and miss counter for EntryProcessor operations JCache: hit and miss counter fail TCK tests for noop EntryProcessor operations Aug 14, 2020
@cruftex cruftex added this to the v1.4 milestone Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

1 participant