jsr107/jsr107spec — Issue #37: Change getCaches generics and signature
Author: gregrluck
Created: 2011-11-10 02:01:52+00:00
State: open

(From Terracotta review)

The CacheManager.getCaches() method appears to declare an bizarre return type:

Set> getCaches();

Unless the user has knowledge of the common key and value super types for all of the caches contained in this cache manager the generic types supplied on calling this method will just lead to troublesome ClassCastExceptions down the road. We believe the more correct generic typing here would be:

Set> getCaches();

We also find the usage of a Set here confusing - the Cache interface declares no explicit equals contract. This leaves implementations free to define there own. A particularly evil implementation could define Cache equality to be universal (all caches are equal to all others). This method would then find it impossible to return the full set of caches from the cache manager while still honoring the Set semantic. It would seem that the fully correct method signature here should be:

Collection> getCaches();