Bug 57352

Summary: NPE in org.apache.poi.hsmf.extractor.OutlookTextExtactor
Product: POI Reporter: Matze M <matthiasmolle>
Component: HSMFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.10-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description Matze M 2014-12-15 18:20:32 UTC
The mothod getText() throws a NullPointerException when extracting text of a msg file with an attachment that has no LongFileName:

      ...
      // Display attachment names
      // To get the attachments, use ExtractorFactory
      for(AttachmentChunks att : msg.getAttachmentFiles()) {
         String ats = att.attachLongFileName.getValue();
         if(att.attachMimeTag != null && 
               att.attachMimeTag.getValue() != null) {
            ats = att.attachMimeTag.getValue() + " = " + ats; 
         }
         s.append("Attachment: " + ats + "\n");
      }
      ...
Comment 1 Nick Burch 2014-12-16 01:40:48 UTC
Do you have a small file you could share that we could use to unit test this? That'll let us ensure it's fixed, and also that it stays fixed into the future!
Comment 2 Matze M 2014-12-19 09:57:14 UTC
Sorry, I recognized this bug while pasing a msg-file I can't give to you.

But the fix should be simple: just add "if (att.attachLongFileName != null)" before "String ats = att.attachLongFileName.getValue();"
or insert a try-catch block inside the for-loop, as aou did for all other values in that method.
Comment 3 Nick Burch 2014-12-19 10:36:42 UTC
Any chance of a file that shows the problem, and a trivial unit test that shows it up? We can then look to fix it, but use the unit test to verify both that it's fixed now, and that it stays fixed into the future!
Comment 4 Dominik Stadler 2016-04-05 12:32:41 UTC
No response for a long time, therefore I think there is not much that we can do for now, please reopen with more information if you still have this problem.
Comment 5 Dominik Stadler 2016-04-05 12:33:37 UTC
Sorry, wrong bug, reopened this again as the fix would be fairly simple here.
Comment 6 Nick Burch 2016-04-06 07:33:33 UTC
Looks like this was fixed in r1694255 in August last year