jackrabbit-oak-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dürig (JIRA) <j...@apache.org>
Subject [jira] [Created] (OAK-6707) TarWriter.close() must not throw an exception on subsequent invocations
Date Fri, 22 Sep 2017 14:35:00 GMT
Michael Dürig created OAK-6707:
----------------------------------

             Summary: 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
             Fix For: 1.8


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)

Mime
View raw message