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

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
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: [hidden email]
          Reporter: [hidden email]
  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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

Eugene <[hidden email]> changed:

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

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #1 from Eugene <[hidden email]> ---
*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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

Eugene <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #2 from PJ Fanning <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #3 from PJ Fanning <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #4 from Dominik Stadler <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #5 from PJ Fanning <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #6 from Eugene <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

--- Comment #7 from PJ Fanning <[hidden email]> ---
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

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

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=64441

PJ Fanning <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]