apex-enterprise-patterns / force-di

Generic DI library with support for Apex, Triggers, Visualforce and Lightning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

di_PlatformCache silently fails

ImJohnMDaniel opened this issue · comments

di_PlatformCache will silently fail under the following conditions:

  • di_Configurations__c.UsePlatformCacheToStoreBindings__c = true
  • di_Configurations__c.OrgCachePartitionName__c specifies a partition name that does not exist
  • the call to retrieve bindings specifies that "empty bindings are allowed"
di_Injector.Org.Bindings.byName(String)
                                        .bySObject(SObjectType)
                                        .emptyBindingsAllowed()
                                        .get();

Under these conditions, the call to di_Binding.get() method first tries to retrieve the bindings from the platform cache. If that returns no bindings and empty bindings are allowed, then the call to loadBindings() method is bypassed.

The root issue is in the method di_PlatformCache.isStoringBindingInPlatformCache(). That method currently only checks value in the di_Configurations__c.UsePlatformCacheToStoreBindings__c field and does not also consider that the partition specified in di_Configurations__c.OrgCachePartitionName__c may not be valid.

The fix should be to change the di_PlatformCache.isStoringBindingInPlatformCache() method to also consider if the partition specified is valid.