You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-issues@jackrabbit.apache.org by "Michael Dürig (JIRA)" <ji...@apache.org> on 2018/02/28 16:41:00 UTC
[jira] [Resolved] (OAK-6707) TarWriter.close() must not throw an
exception on subsequent invocations
[ https://issues.apache.org/jira/browse/OAK-6707?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael Dürig resolved OAK-6707.
--------------------------------
Resolution: Fixed
Fixed at http://svn.apache.org/viewvc?rev=1825582&view=rev
> TarWriter.close() must not throw an exception on subsequent invocations
> -----------------------------------------------------------------------
>
> Key: OAK-6707
> URL: https://issues.apache.org/jira/browse/OAK-6707
> Project: Jackrabbit Oak
> Issue Type: Bug
> Components: segment-tar
> Reporter: Michael Dürig
> Assignee: Michael Dürig
> Priority: Minor
> Labels: technical_debt
> Fix For: 1.9.0, 1.10
>
>
> Invoking TarWriter.close() on an already closed writer throws an {{ISE}}. According to the general contract this is not allowed:
> {code}
> * Closes this stream and releases any system resources associated
> * with it. If the stream is already closed then invoking this
> * method has no effect.
> {code}
> We should adjust the behvaviour of that method accordingly.
> Failing to comply with that general contract causes {{TarWriter}} instances to fail in try-resource statements when multiple wrapped streams are involved.
> Consider
> {code}
> try (
> StringWriter string = new StringWriter();
> PrintWriter writer = new PrintWriter(string);
> WriterOutputStream out = new WriterOutputStream(writer, Charsets.UTF_8))
> {
> dumpHeader(out);
> writer.println("----------------------------------------");
> dumpHex(out);
> writer.println("----------------------------------------");
> return string.toString();
> }
> {code}
> This code would cause exceptions to be thrown if e.g. the {{PrintWriter.close}} method would not be idempotent.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)