[ 
https://issues.apache.org/jira/browse/METAMODEL-32?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kasper Sørensen resolved METAMODEL-32.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0
         Assignee: Kasper Sørensen

> Excel module: XlsxSpreadsheetReaderDelegate is not thread safe
> --------------------------------------------------------------
>
>                 Key: METAMODEL-32
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-32
>             Project: Metamodel
>          Issue Type: Bug
>            Reporter: Kasper Sørensen
>            Assignee: Kasper Sørensen
>             Fix For: 4.0
>
>
> XlsxSpreadsheetReaderDelegate uses a HashMap to store references to table 
> names and internal IDs. It may occur that a new table is created, it's 
> reference added to this HashMap, and then queried shortly after by another 
> thread. But since HashMaps are not threadsafe or volatile, it may occur that 
> the other thread will get a dirty write which will result in a stack trace 
> like this because of a null reference passed on:
> {code}
> java.lang.NullPointerException: null
> at java.util.TreeMap.getEntry(TreeMap.java:342) ~[na:1.7.0_45]
> at java.util.TreeMap.get(TreeMap.java:273) ~[na:1.7.0_45]
> at 
> org.apache.poi.openxml4j.opc.PackageRelationshipCollection.getRelationshipByID(PackageRelationshipCollection.java:282)
>  ~[poi-ooxml-3.8.jar:3.8]
> at 
> org.apache.poi.openxml4j.opc.PackagePart.getRelationship(PackagePart.java:379)
>  ~[poi-ooxml-3.8.jar:3.8]
> at 
> org.apache.poi.xssf.eventusermodel.XSSFReader.getSheet(XSSFReader.java:139) 
> ~[poi-ooxml-3.8.jar:3.8]
> at 
> org.eobjects.metamodel.excel.XlsxRowPublisherAction.run(XlsxRowPublisherAction.java:56)
>  ~[MetaModel-excel-3.4.7.jar:na]
> at 
> org.eobjects.metamodel.excel.XlsxRowPublisherAction.run(XlsxRowPublisherAction.java:36)
>  ~[MetaModel-excel-3.4.7.jar:na]
> at 
> org.eobjects.metamodel.data.RowPublisherDataSet$1.run(RowPublisherDataSet.java:88)
>  ~[MetaModel-core-3.4.7.jar:na]
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) 
> ~[na:1.7.0_45]
> at java.util.concurrent.FutureTask.run(FutureTask.java:262) ~[na:1.7.0_45]
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>  [na:1.7.0_45]
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>  [na:1.7.0_45]
> at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
> {code}
> I suggest simply replacing the HashMap with a ConcurrentHashMap, since that 
> will fix the issue. Furthermore we should check the used ID for null, so that 
> we fail fast and avoid this stack which initially got us thinking it was an 
> Apache POI issue.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to