public static <T> T getObjectOfType(String classOrMethod, Class<T> expectedClazz) {
    T object;
    try {
      object = getObjectOfTypeFromClassName(classOrMethod, expectedClazz);
    } catch (Exception ignore) {
      object = getObjectOfTypeFromFactoryMethod(classOrMethod);
    }
    return object;
  }
this method would never return null, it either throws an exception or returns an object

@return an object of type expectedClazz. This method would never return null. It either returns
        an non-null object or throws exception.
geode-core/src/main/java/org/apache/geode/internal/security/CallbackInstantiator.java