Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-2424

ClassCastException in getMetaData if no real meta data

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.7, 1.8.8, 2.0.0
    • Fix Version/s: 1.8.8, 2.0.0
    • Component/s: Parsing
    • Labels:
      None

      Description

      Here's an exception from Tim Allison latest TIKA test (too lazy to test it myself, the cause is obvious) with the attached file:

      org.apache.tika.exception.TikaException: Unexpected RuntimeException from org.apache.tika.parser.pdf.PDFParser
      	at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:249)
      	at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:247)
      	at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:120)
      	at org.apache.tika.parser.RecursiveParserWrapper.parse(RecursiveParserWrapper.java:137)
      	at org.apache.tika.batch.fs.RecursiveParserWrapperFSConsumer.processFileResource(RecursiveParserWrapperFSConsumer.java:120)
      	at org.apache.tika.batch.FileResourceConsumer._processFileResource(FileResourceConsumer.java:153)
      	at org.apache.tika.batch.FileResourceConsumer.call(FileResourceConsumer.java:96)
      	at org.apache.tika.batch.FileResourceConsumer.call(FileResourceConsumer.java:38)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:724)
      Caused by: java.lang.ClassCastException: org.apache.pdfbox.cos.COSDictionary cannot be cast to org.apache.pdfbox.cos.COSStream
      	at org.apache.pdfbox.pdmodel.PDDocumentCatalog.getMetadata(PDDocumentCatalog.java:312)
      	at org.apache.tika.parser.pdf.PDFParser.extractMetadata(PDFParser.java:181)
      	at org.apache.tika.parser.pdf.PDFParser.parse(PDFParser.java:158)
      	at org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:247)
      	... 13 more
      "
      

      here's the excerpt in the PDF:

      241 0 obj << /Type /Metadata /Subtype /XML >> endobj
      

      the current code is

              COSStream stream = (COSStream)root.getDictionaryObject( COSName.METADATA );
      

      shall we keep it that way or rather put out a warning if the meta data is not a stream and return null? Adobe Reader does nothing when looking for the properties.

        Attachments

        1. 333472.pdf
          241 kB
          Tilman Hausherr

          Activity

            People

            • Assignee:
              tilman Tilman Hausherr
              Reporter:
              tilman Tilman Hausherr
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: