GROOVY-6895: Add null check to avoid errors to be swallowed