From 2f9219c25f51c2b353db2aa48284d12512c40144 Mon Sep 17 00:00:00 2001 From: John Whish Date: Wed, 1 May 2024 16:34:44 +0100 Subject: [PATCH] Cache policies LRU error (#590) COLDBOX-1280 https://ortussolutions.atlassian.net/browse/COLDBOX-1280 #Resolve * check if md keys exist before referencing Fixes error: Error sorting via store indexer Element TIMEOUT is undefined in MD. coldfusion.runtime.UndefinedElementException: Element TIMEOUT is undefined in MD. * Add default value if missing Fixes error: Error sorting via store indexer Invalid property requested: isSoftReference Valid properties are: coldfusion.runtime.CustomException: Invalid property requested: isSoftReference --- system/cache/policies/AbstractEvictionPolicy.cfc | 3 +++ system/cache/store/ConcurrentSoftReferenceStore.cfc | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/system/cache/policies/AbstractEvictionPolicy.cfc b/system/cache/policies/AbstractEvictionPolicy.cfc index e9569f60f..0da5c7ae9 100644 --- a/system/cache/policies/AbstractEvictionPolicy.cfc +++ b/system/cache/policies/AbstractEvictionPolicy.cfc @@ -83,6 +83,9 @@ component continue; } var md = indexer.getObjectMetadata( item ); + if ( NOT md.keyExists( "timeout" ) || NOT md.keyExists( "isExpired" ) ) { + continue; + } // Evict if not already marked for eviction or an eternal object. if ( md.timeout GT 0 AND NOT md.isExpired ) { diff --git a/system/cache/store/ConcurrentSoftReferenceStore.cfc b/system/cache/store/ConcurrentSoftReferenceStore.cfc index 70e973368..908b210c7 100644 --- a/system/cache/store/ConcurrentSoftReferenceStore.cfc +++ b/system/cache/store/ConcurrentSoftReferenceStore.cfc @@ -189,7 +189,8 @@ component extends="coldbox.system.cache.store.ConcurrentStore" accessors=true { if ( !isNull( local.softRef ) && variables.indexer.getObjectMetadataProperty( arguments.objectKey, - "isSoftReference" + "isSoftReference", + false ) ) { variables.softRefKeyMap.remove( softRef.hashCode() );