Can restTemplate.getForObject("URL", Object[].class) return NULL?

Viewed 6049

I have used the solution from this answer: Get list of JSON objects with Spring RestTemplate It works perfectly. It doing exactly what I need.

ProcessDefinition[] response = restTemplate.getForObject(url, ProcessDefinition[].class);

Is it enought:

return Arrays.asList(response);

or will be better this way:

return Arrays.asList(Optional.ofNullable(response).orElse(new ProcessDefinition[0]));

P.S. Sorry for starting the new topic, but my karma does not allow me to comment the answer.

1 Answers
Related