Avoid possible NullPointerException when retrieving repository