Skip to content

Commit 9b3f7b6

Browse files
authored
fixed unhandled IOException
1 parent b43c340 commit 9b3f7b6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

dspace-api/src/main/java/org/dspace/subscriptions/ContentGenerator.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,22 @@ private String generateBodyMail(Context context, List<IndexableObject> indexable
7878
if (indexableObjects == null) {
7979
return EMPTY;
8080
}
81-
ByteArrayOutputStream out = new ByteArrayOutputStream();
82-
out.write("\n".getBytes(UTF_8));
8381
try {
82+
ByteArrayOutputStream out = new ByteArrayOutputStream();
83+
out.write("\n".getBytes(UTF_8));
8484
for (IndexableObject indexableObject : indexableObjects) {
8585
out.write("\n".getBytes(UTF_8));
8686
Item item = (Item) indexableObject.getIndexedObject();
8787
String entityType = itemService.getEntityTypeLabel(item);
8888
Optional.ofNullable(entityType2Disseminator.get(entityType))
8989
.orElseGet(() -> entityType2Disseminator.get("Item"))
9090
.disseminate(context, item, out);
91-
}
91+
}
92+
return out.toString();
9293
} catch (Exception e) {
9394
log.error(e.getMessage(), e);
9495
}
95-
return out.toString();
96+
return EMPTY;
9697
}
9798

9899
public void setEntityType2Disseminator(Map<String, StreamDisseminationCrosswalk> entityType2Disseminator) {

0 commit comments

Comments
 (0)