Skip to content

Commit 7def15c

Browse files
committed
Fix #37 - Distinguish between NPE errors and zero byte attachments.
1 parent a913719 commit 7def15c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/pt/cjmach/pstconv/PstConverter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,11 @@ void convertAttachments(PSTMessage message, MimeMultipart rootMultipart) throws
442442

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

451452
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
@@ -495,7 +496,7 @@ static byte[] getAttachmentBytes(PSTAttachment attachment) throws PSTException,
495496
try {
496497
input = attachment.getFileInputStream();
497498
} catch (NullPointerException ex) {
498-
return new byte[0];
499+
return null;
499500
}
500501
try {
501502
int nread;

0 commit comments

Comments
 (0)