commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Dever <jsde...@sympatico.ca>
Subject Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient RequestOutputStream.java
Date Mon, 05 Aug 2002 13:39:56 GMT
>
>
>   -        if (this.closed == false) {
>   +        if (!closed) {
>                try {
>   -            if (useChunking) {
>   -               // Write the final chunk.
>   -               stream.write(zero, 0, zero.length);
>   -               stream.write(crlf, 0, crlf.length);
>   -               stream.write(endChunk, 0, endChunk.length);
>   -               if(wireLog.isDebugEnabled()) {
>   -                  wireLog.debug(">> byte 0 \\r\\n\\r\\n (final chunk)");
>   -               }
>   -            }
>   -            super.close();
>   +                if (useChunking) {
>   +                    // Write the final chunk.
>   +                    stream.write(ZERO, 0, ZERO.length);
>   +                    stream.write(CRLF, 0, CRLF.length);
>   +                    stream.write(ENDCHUNK, 0, ENDCHUNK.length);
>   +                    wireLog.debug(">> byte 0 \\r\\n\\r\\n (final chunk)");
>   +                }
>   +                super.close();
>                } catch (IOException ioe) {
>   -             log.debug("Unexpected exception caught when closing output stream", ioe);
>   +                log.debug("Unexpected exception caught when closing output "
>   +                    + " stream", ioe);
>                    throw ioe;
>                } finally {
>                    this.closed = true;
>

The close is done in the try block, but the closed=true is done in the finally block.  Could
lead to an unclosed
stream bbut closed==true if the write throws.  close() should be in the finally (will have
to swallow an exception
thrown on the close).


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message