check null value of bitstream name before quoting name for regex

This commit is contained in:
Gantner, Florian Klaus
2023-10-12 17:58:13 +02:00
parent a124807468
commit a9bcc0c223

View File

@@ -403,7 +403,9 @@ public class BitstreamServiceImpl extends DSpaceObjectServiceImpl<Bitstream> imp
@Override
public Bitstream getThumbnail(Context context, Bitstream bitstream) throws SQLException {
Pattern pattern = Pattern.compile("^" + Pattern.quote(bitstream.getName()) + ".([^.]+)$");
Pattern pattern = Pattern.compile("^" +
(bitstream.getName() != null ? Pattern.quote(bitstream.getName()) : bitstream.getName())
+ ".([^.]+)$");
for (Bundle bundle : bitstream.getBundles()) {
for (Item item : bundle.getItems()) {