apex-enterprise-patterns/force-di

Null Pointer Exception found in certain scenarios

ImJohnMDaniel opened this issue · 0 comments

A Null Pointer exception has been observed in certain conditions. Specifically, the di_Injector's method getInstance(String, Schema.SObjectType, Object) could through an NPE when the bindingsFound returns a null entry.

        List<di_Binding> bindingsFound = this.Bindings.bySObject( bindingSObjectType )
                                            .byName( developerName.toLowerCase().trim() )
                                            .get();

        if ( bindingsFound == null || bindingsFound.isEmpty() ) {
            throw new InjectorException('Binding for "' + developerName + '" and SObjectType "' + bindingSObjectType + '" not found');
        }
        return bindingsFound[0].getInstance(params);

If bindingsFound contains a null in the first position of the list, the di_Bindings.getInstance(Object) call will fail.