Hi, As the FAQ entry explains you need to synchronize access to a single Workbook in your code, so the options are either doing that synchronization whenever your threads access the workbook so only one thread is ever accessing the workbook or doing the changes in multiple separate workbooks and copying the results into the final workbook at the end in a single thread.
It depends on your actual use-case which option is better suited. Dominik. On Thu, Aug 23, 2018 at 11:39 PM, Greg Woolsey <[email protected]> wrote: > You can investigate the source and see, but the reason POI is not thread > safe is because it is extremely difficult to do with projects based on > XML-Beans. The POI team has no plans to revisit the subject at this point. > > On Thu, Aug 23, 2018 at 12:24 PM Pavel Drankov <[email protected]> > wrote: > > > > > > > See question 20 from the POI FAQ [1]. Accessing the same document > > objects > > > from multiple threads is not supported. > > > > Good, but can we make these objects thread safe at least? > > > > On Thu, 23 Aug 2018 at 19:22, Greg Woolsey <[email protected]> > wrote: > > > > > See question 20 from the POI FAQ [1]. Accessing the same document > > objects > > > from multiple threads is not supported. > > > > > > [1] https://poi.apache.org/faq.html > > > > > > On Thu, Aug 23, 2018 at 3:47 AM Pavel Drankov <[email protected]> > > wrote: > > > > > > > Hi, > > > > > > > > I have an instance of SXSSFSheet and when I'm trying to fill it with > > > > values concurrently, such exceptions occurs: > > > > > > > > java.util.ConcurrentModificationException: null > > > > at java.util.TreeMap$PrivateEntryIterator. > nextEntry(TreeMap.java:1211) > > > > ~[na:1.8.0_152] > > > > at java.util.TreeMap$EntryIterator.next(TreeMap.java:1247) > > > ~[na:1.8.0_152] > > > > at java.util.TreeMap$EntryIterator.next(TreeMap.java:1242) > > > ~[na:1.8.0_152] > > > > at > > > org.apache.poi.xssf.streaming.SXSSFSheet.getRowNum( > SXSSFSheet.java:1851) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > at org.apache.poi.xssf.streaming.SXSSFRow.getRowNum(SXSSFRow. > java:218) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > at > > org.apache.poi.xssf.streaming.SXSSFCell.getRowIndex(SXSSFCell.java:84) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > at > > > org.apache.poi.xssf.streaming.SXSSFCell.setHyperlink( > SXSSFCell.java:649) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > > > > > java.lang.NullPointerException: null > > > > at > > > > > > > > > > > > > org.apache.poi.xssf.streaming.AutoSizeColumnTracker.updateColumnWidths( > AutoSizeColumnTracker.java:302) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > at > > > > > > > > > org.apache.poi.xssf.streaming.SXSSFSheet.flushOneRow( > SXSSFSheet.java:1834) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > at > > > org.apache.poi.xssf.streaming.SXSSFSheet.flushRows( > SXSSFSheet.java:1813) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > at > > > org.apache.poi.xssf.streaming.SXSSFSheet.createRow( > SXSSFSheet.java:155) > > > > ~[poi-ooxml-3.14.jar:3.14] > > > > > > > > I put synchronization on the object access and it works fine now, but > > is > > > > not it an issue? Should the SXSSFCell and SXSSFSheet objects be > thread > > > > safe? > > > > > > > > Best wishes, > > > > Pavel > > > > > > > > > >
