You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2020/05/14 16:43:38 UTC

[Bug 64441] New: WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

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: dev@poi.apache.org
          Reporter: berek@bk.ru
  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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #4 from Dominik Stadler <do...@gmx.at> ---
The test is very unlikely to trigger it as it only can happen for the first two
executions of the future, after that the variable is initialized, 

Maybe we can somehow "uninitialize" it again, otherwise it will fail very very
rarely.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #3 from PJ Fanning <fa...@yahoo.com> ---
I added this test
https://github.com/apache/poi/commit/24345edd5e7a98089abac93417522cced20025f0
but it passes.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #2 from PJ Fanning <fa...@yahoo.com> ---
as a workaround, you should be able to use write a wrapper that has
synchronization

you could also try using `new HSSFWorkbook(stream)`

ideally, the code should support concurrent use but any fix we do could take
months to appear in a release

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #5 from PJ Fanning <fa...@yahoo.com> ---
I added some synchronization in
https://svn.apache.org/viewvc?view=revision&revision=1877776

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #1 from Eugene <be...@bk.ru> ---
*And sometimes the second thread does not go into this condition and thinks
that createHssfByNode is already initialized, which is why this error comes in.

Sorry, for some reason I can’t edit the description.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

Eugene <be...@bk.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

Eugene <be...@bk.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |berek@bk.ru

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #7 from PJ Fanning <fa...@yahoo.com> ---
If no bugs found in it, it will be in the next release but there is no date yet
for that release.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 64441] WorkbookFactory.create(InputStream inp) nullpointer error in multithreding

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #6 from Eugene <be...@bk.ru> ---
Thanks for the quick answers and fix! Do you think this fix can be included in
4.1.3 release?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org