https://bz.apache.org/bugzilla/show_bug.cgi?id=64441
Bug ID: 64441
Summary: WorkbookFactory.create(InputStream inp) nullpointer
error in multithreding
Product: POI
Version: 4.1.2-FINAL
Hardware: PC
Status: NEW
Severity: critical
Priority: P2
Component: HSSF
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
When calling a WorkbookFactory.create(InputStream inp) method from multiple
threads sometimes following error appears:
Caused by: java.lang.NullPointerException
at org.apache.poi.ss.usermodel.WorkbookFactory.create
(WorkbookFactory.java:167)
at org.apache.poi.ss.usermodel.WorkbookFactory.create
(WorkbookFactory.java:112)
at org.apache.poi.ss.usermodel.WorkbookFactory.create
(WorkbookFactory.java:253)
at org.apache.poi.ss.usermodel.WorkbookFactory.create
(WorkbookFactory.java:221)
the reason for this is that in HSSFWorkbookFactory class
WorkbookFactory.createHssfByNode field is null in this block:
try {
initHssf();
return createHssfByNode.apply(root);
}
first thread starts initialization:
private static void initHssf() throws IOException {
if (createHssfFromScratch == null) {
// HSSF is part of the main jar, so this shouldn't fail ...
initFactory("org.apache.poi.hssf.usermodel.HSSFWorkbookFactory",
"poi-*.jar");
}
}
And sometimes the second thread does not go into this condition and thinks that
123 is already initialized, which is why this error comes in.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]