You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Jeff Dever <js...@sympatico.ca> on 2002/08/05 15:39:56 UTC
Re: cvs commit:
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient
RequestOutputStream.java
>
>
> - 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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>