Fix for PDI-11431
only access r if r is not null