Extract duplicated null checks to method in ClientProvider.