jsr107 / jsr107spec

JSR107 Cache Specification
Apache License 2.0
413 stars 164 forks source link

CompleteConfiguration.isWriteThrough issues #406

Open cruftex opened 5 years ago

cruftex commented 5 years ago

The specified effect of CompleteConfiguration.isWriteThrough is not being tested via the TCK, and probably not really implemented like the spec says by caching providers.

In JCache its possible to define a loader that will be used in case of loadAll is invoked, and, in case readThrough is enabled the loader is invoked automatically in case a mapping is missing.

Consequently there is the possibility to define a writer and enable write through via CompleteConfiguration.isWriteThrough. However, there are actually no explicitly defined semantics for the case that the writer is defined but write through is not enabled.

In the cache2k JSR107 implementation I simply ignore the write through flag. That means that the TCK does not require write through to be enabled for the write through tests.

There is no test or defined behavior for the illegal configuration of write through being enabled but no writer defined. Checking the RI code I assume it crashes with NPE on Cache.put but does proceed normally on Cache.putAll.

Two options to mitigate this irritation:

  1. Deprecate and make clear that CompleteConfiguration.isWriteThrough has no effect and can be ignored and the write through is enabled via defining a writer.
  2. Improve the TCK and RI that isWriteThrough must be enabled, and add tests for the invalid configuration

I recommend doing 1, because option 2 would mean that implementations and applications have to change without any benefit.