You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The GrailsConcurrentLinkedMapCache.put method is as follows:
public void put(Object key, Object value) {
this.store.put(key, toStoreValue(value));
}
If I configure the cache to not allow null entries, calling the above with ('aKey', null) will try to put a null value into the underlying ConcurrentLinkedHashMap, which causes a NPE to be thrown by that class's checkNotNull assertion on the value
I was able to get around this be subclassing GrailsConcurrentLinkedMapCache and overriding put with:
java.lang.NullPointerException
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.checkNotNull(ConcurrentLinkedHashMap.java:254)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.put(ConcurrentLinkedHashMap.java:718)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.put(ConcurrentLinkedHashMap.java:698)
at grails.plugin.cache.GrailsConcurrentLinkedMapCache.put(GrailsConcurrentLinkedMapCache.java:115)
at com.rgatp.ng.disclosures.api.DecodedInterviewControllerSpec.test it(DecodedInterviewControllerSpec.groovy:19)
The text was updated successfully, but these errors were encountered:
mmeusey
changed the title
Error in GrailsConcurrentLinkedMapCache.put when excluding null values
Error in GrailsConcurrentLinkedMapCache.put when excluding null values (v 4.0.0)
Oct 28, 2019
The GrailsConcurrentLinkedMapCache.put method is as follows:
public void put(Object key, Object value) {
this.store.put(key, toStoreValue(value));
}
If I configure the cache to not allow null entries, calling the above with ('aKey', null) will try to put a null value into the underlying ConcurrentLinkedHashMap, which causes a NPE to be thrown by that class's checkNotNull assertion on the value
I was able to get around this be subclassing GrailsConcurrentLinkedMapCache and overriding put with:
If I understand correctly, this was the intended behavior.
Simple test:
void 'test it'() {
given:
GrailsConcurrentLinkedMapCache cache = new GrailsConcurrentLinkedMapCache('name', 10, false)
when:
cache.put('key', null)
then:
null == cache.get('key')
}
yields
java.lang.NullPointerException
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.checkNotNull(ConcurrentLinkedHashMap.java:254)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.put(ConcurrentLinkedHashMap.java:718)
at com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap.put(ConcurrentLinkedHashMap.java:698)
at grails.plugin.cache.GrailsConcurrentLinkedMapCache.put(GrailsConcurrentLinkedMapCache.java:115)
at com.rgatp.ng.disclosures.api.DecodedInterviewControllerSpec.test it(DecodedInterviewControllerSpec.groovy:19)
The text was updated successfully, but these errors were encountered: