Description
AffinityFunction implementations must check for null keys and through meaningful exceptions in such a cases.
As an example the following code trows NPE since the keys is not validated
Cache<AffinityKey<String>, Person> personCache = ..; personCache.get(new AffinityKey<>(key, affKey)); // returns value personCache.get(new AffinityKey<>(key)); // throws NPE Exception in thread "main" java.lang.NullPointerException at org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction.partition(RendezvousAffinityFunction.java:428) at org.apache.ignite.internal.processors.cache.GridCacheAffinityManager.partition(GridCacheAffinityManager.java:206) at org.apache.ignite.internal.processors.cache.GridCacheContext.toCacheKeyObject(GridCacheContext.java:1801) at org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.get(GridDhtAtomicCache.java:339) at org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:4650) at org.apache.ignite.internal.processors.cache.GridCacheAdapter.get(GridCacheAdapter.java:1391) at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.get(IgniteCacheProxy.java:907) at my.apache.ignite.examples.collocation.CacheCollocationExample.main(CacheCollocationExample.java:69)
Attachments
Issue Links
- links to