[ 
https://issues.apache.org/jira/browse/OAK-6707?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Dürig updated OAK-6707:
-------------------------------
    Fix Version/s:     (was: 1.8)

> 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
>            Priority: Minor
>
> 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
(v6.4.14#64029)

Reply via email to