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 2016/05/25 14:46:53 UTC
[Bug 59634] New: XSSFWorkbook#close() violates contract from
Workbook#close()
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
Bug ID: 59634
Summary: XSSFWorkbook#close() violates contract from
Workbook#close()
Product: POI
Version: 3.14-FINAL
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: michael.holtermann@dfb-medien.de
Created attachment 33890
--> https://bz.apache.org/bugzilla/attachment.cgi?id=33890&action=edit
TestCase demonstrating the issue
According to Workbook#close() it should not have any effect on newly created
workbooks.
This is true for HSSFWorkbooks.
For XSSFWorkbooks it's not possible to write the document to an OutputStream
after calling #close().
Since I'm mostly creating Workbooks from scratch, I thought I can call #close()
just after creation of Worbook, instead of somewhere later when the document
was written to outside world.
Please see the attached test case that should demonstrate the issue.
(Side note: The documentation states #close() will close the underlying input
resource the Workbook was created from (e.g. calls to constructor
HSSFWorkbook(InputStream)?). Shouldn't be the creator of that InputStream
responsible for closing that Stream?)
Regards,
Michael
--
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
Re: [Bug 59634] XSSFWorkbook#close() violates contract from Workbook#close()
Posted by Dominik Stadler <do...@gmx.at>.
+1, close() is the final thing you do on objects based on the Closeable
interface, I am surprised the javadoc for Workbook states it differently.
If we want to have a way to "release" resources while still having the
object available, we should use a differently named method for this as
close() is very much Java-standard and many developers will expect it to
behave in this way.
Dominik.
On Fri, May 27, 2016 at 1:44 PM, Murphy, Mark <mu...@metalexmfg.com>
wrote:
> This seems a little counterintuitive to me. I would expect that once a
> Workbook is closed, it cannot be used. Closing should be the last thing you
> do with a Workbook. I would be more inclined to fix the documentation than
> to allow differing behavior between Workbooks read from the file system,
> and newly created workbooks.
>
> -----Original Message-----
> From: bugzilla@apache.org [mailto:bugzilla@apache.org]
> Sent: Thursday, May 26, 2016 2:41 AM
> To: dev@poi.apache.org
> Subject: [Bug 59634] XSSFWorkbook#close() violates contract from
> Workbook#close()
>
> https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
>
> --- Comment #1 from Michael <mi...@dfb-medien.de> --- In
> addition it's not possible to read from the workbook after it has been
> closed. A NPE will be thrown.
>
> --
> 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
>
>
RE: [Bug 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by "Murphy, Mark" <mu...@metalexmfg.com>.
This seems a little counterintuitive to me. I would expect that once a Workbook is closed, it cannot be used. Closing should be the last thing you do with a Workbook. I would be more inclined to fix the documentation than to allow differing behavior between Workbooks read from the file system, and newly created workbooks.
-----Original Message-----
From: bugzilla@apache.org [mailto:bugzilla@apache.org]
Sent: Thursday, May 26, 2016 2:41 AM
To: dev@poi.apache.org
Subject: [Bug 59634] XSSFWorkbook#close() violates contract from Workbook#close()
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
--- Comment #1 from Michael <mi...@dfb-medien.de> --- In addition it's not possible to read from the workbook after it has been closed. A NPE will be thrown.
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
--- Comment #1 from Michael <mi...@dfb-medien.de> ---
In addition it's not possible to read from the workbook after it has been
closed. A NPE will be thrown.
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |scorpdaddy.ch@gmail.com
CC| |jbatchelor@mutualnc.com
--- Comment #6 from Dominik Stadler <do...@gmx.at> ---
*** Bug 59356 has been marked as a duplicate of this bug. ***
--- Comment #7 from Dominik Stadler <do...@gmx.at> ---
*** Bug 53613 has been marked as a duplicate of this bug. ***
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
The JavaDoc was partly updated in r1749213 and further refined in r1753912 to
state that the close() call may also invalidate other things and should only be
called before work with the object is done.
I have also removed the "has no effect on newly created... ", as I don't think
we should limit ourselves this way here, we should be able to do optimizations
in the future which make use of this. All other Java Closables do it this way
and thus let's do the same here.
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
Javen O'Neal <on...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |59287
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
For dicussion, the current javadoc for Workbook.close() is
* Close the underlying input resource (File or Stream),
* from which the Workbook was read. After closing, the
* Workbook should no longer be used.
* <p>This will have no effect newly created Workbooks.
HSSFWorkbook.close()
* Closes the underlying {@link NPOIFSFileSystem} from which
* the Workbook was read, if any. Has no effect on Workbooks
* opened from an InputStream, or newly created ones.
XSSFWorkbook.close()
* Closes the underlying {@link OPCPackage} from which this
* document was read, if there is one
We should probably rephrase those to state more in the order of "do not use at
all after closing" and "it will close resources that have been passed in the
constructor". This makes it as simple as possible and does not lead to very
hard to find bugs if passed in resources are closed at some point.
This way would also be consistent with what many other Java-Closeable-instances
will do when they receive some resource themselves, e.g. see
FileInputStreamReader, FileOutputStreamWriter, ...
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |59678
CC| |hartmut_juergens@yahoo.de
--- Comment #4 from Dominik Stadler <do...@gmx.at> ---
*** Bug 59678 has been marked as a duplicate of this bug. ***
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lianyining@hotmail.com
--- Comment #8 from Dominik Stadler <do...@gmx.at> ---
*** Bug 60754 has been marked as a duplicate of this bug. ***
--
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 59634] XSSFWorkbook#close() violates contract from
Workbook#close()
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59634
--- Comment #3 from Michael <mi...@dfb-medien.de> ---
Sounds legit. I'd support that solution.
--
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