Fix issue found by sonar: Method call on object which may be null

Change-Id: I937dddbe08fa12cbe38ad01a5990a90c4ac19df1
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
(cherry picked from commit 1cb22a07c5df2da16abf5dc04754ad8cd0a69cb5)