Skip to content

Commit

Permalink
Fix #37 - Distinguish between NPE errors and zero byte attachments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmach committed Nov 2, 2024
1 parent a913719 commit 7def15c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/pt/cjmach/pstconv/PstConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,11 @@ void convertAttachments(PSTMessage message, MimeMultipart rootMultipart) throws

if (attachment != null) {
byte[] data = getAttachmentBytes(attachment);
if (data.length == 0) {
if (data == null) {
logger.warn("Failed to extract bytes of attachment {} from message {}.",
attachment.getDescriptorNodeId(), message.getDescriptorNodeId());
// try to add the attachment, which may still be useful even without its contents.
data = new byte[0];
}

MimeBodyPart attachmentBodyPart = new MimeBodyPart();
Expand Down Expand Up @@ -495,7 +496,7 @@ static byte[] getAttachmentBytes(PSTAttachment attachment) throws PSTException,
try {
input = attachment.getFileInputStream();
} catch (NullPointerException ex) {
return new byte[0];
return null;
}
try {
int nread;
Expand Down

0 comments on commit 7def15c

Please sign in to comment.