[
https://issues.apache.org/jira/browse/PDFBOX-2862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14620460#comment-14620460
]
Timo Boehme commented on PDFBOX-2862:
-------------------------------------
As I understand it the problem is that in the static constructor the instance
constructor is called. Thus the class will be in the state 'initialized' before
the static constructor has finished. Therefore parallel access via static
methods are possible, getting the DEFAULT Glyphlist which is currently filled
by static constructor.
It might be enough to place the static methods _after_ the static constructor
since initialization is done in the order it appears within the class
(http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4).
However I would recommend a static init method and a static AtomicBoolean
IS_INITIALIZED variable. The init-method will be called first by all static
methods and the instance constructor. The method itself checks state of
IS_INITIALIZED and if false, synchronizes on this variable, checks again and
does all the things currently in the static constructor. The static Glyphlist
variables may also be set to 'volatile' in order for other threads to see the
correct value in this case.
> GlyphList doesn't appear to be thread safe in trunk...or user error?
> --------------------------------------------------------------------
>
> Key: PDFBOX-2862
> URL: https://issues.apache.org/jira/browse/PDFBOX-2862
> Project: PDFBox
> Issue Type: Bug
> Affects Versions: 2.0.0
> Reporter: Tim Allison
> Attachments: batch-process-warn-first10klines.log.bz2
>
>
> This could be user error, but I'm getting the following when running trunk in
> a multithreaded environment.
> {noformat}
> Caused by: java.util.ConcurrentModificationException
> at java.util.HashMap$HashIterator.nextEntry(HashMap.java:922)
> at java.util.HashMap$EntryIterator.next(HashMap.java:962)
> at java.util.HashMap$EntryIterator.next(HashMap.java:960)
> at java.util.HashMap.putAllForCreate(HashMap.java:554)
> at java.util.HashMap.<init>(HashMap.java:298)
> at
> org.apache.pdfbox.pdmodel.font.encoding.GlyphList.<init>(GlyphList.java:114)
> at
> org.apache.pdfbox.text.PDFTextStreamEngine.<init>(PDFTextStreamEngine.java:103)
> at
> org.apache.pdfbox.text.PDFTextStripper.<init>(PDFTextStripper.java:196)
> at
> org.apache.tika.parser.pdf.PDF2XHTML.<init>(PDF2XHTML.java:106)
> at org.apache.tika.parser.pdf.PDF2XHTML.process(PDF2XHTML.java:133)
> at org.apache.tika.parser.pdf.PDFParser.parse(PDFParser.java:132)
> at
> org.apache.tika.parser.CompositeParser.parse(CompositeParser.java:281)
> ... 16 more
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]