Hi, In my application I found from time to time some hanging Threads. The Threaddumps are always pointing to the POI IntMapper class at java.util.HashMap.get(java.lang.Object) at org.apache.poi.util.IntMapper.getIndex(java.lang.Object) at org.apache.poi.hssf.record.SSTRecord.addString(org.apache.poi.hssf.record.UnicodeString) at org.apache.poi.hssf.model.Workbook.addSSTString(org.apache.poi.hssf.record.UnicodeString) at org.apache.poi.hssf.usermodel.HSSFCell.setCellValue(org.apache.poi.ss.usermodel.RichTextString) We are using POI 3.6 but since then, only some code clean up (0111e33d) happened. This problem probably exists in newer Versions too. I even found some references in the internet with the same problem: - http://mail-archives.apache.org/mod_mbox/poi-user/201212.mbox/%3Cloom.20121220T112250-206@post.gmane.org%3E - http://cueabsorb.wordpress.com/2010/12/15/%E4%BD%BF%E7%94%A8hashmap%E5%AF%BC%E8%87%B4cpu-200%E6%88%96%E8%80%85%E5%AF%BC%E8%87%B4%E7%9A%84load-%E9%A3%99%E9%AB%98%E9%97%AE%E9%A2%98/
What are you doing to trigger it? Is there any chance you could be allowing two different threads to work on the same open workbook? (POI is designed to allow multiple different threads to each access their own different workbooks, but it isn't designed to let multiple threads work on the very same workbook object) As it stands, I can't see anything that might explain why the code would lock up in regular operation (other than a JVM bug)
(In reply to comment #1) > What are you doing to trigger it? I profiled the JVM to get the stacktrace. It's a race condition, as the application is already running several days. > Is there any chance you could be allowing two different threads to work on > the same open workbook? Yes. It seems like a new bug in our application circumvents the synchronization of the workbook. I'm closing the bug. Thx.
Just to confirm for anyone looking later and wondering about threading with POI: Two threads, each working on different workbooks (or other file formats) should always be fine Two threads, trying to work on the same workbook object (or same slideshow, word doc, poifsfilesystem etc) is not supported Each workbook / filesystem / etc must only be worked on by one thread. Multiple threads must each work with their own objects