PDFBOX-4071, PDFBOX-4151: avoid potential ClassCastException, avoid returning null (see trunk rev 1824680)