commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@multitask.com.au
Subject Re: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient RequestOutputStream.java
Date Mon, 05 Aug 2002 15:06:45 GMT
jsdever wrote on 08/05/2002 11:39:56 PM:

> >
> >
> >   -        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).

Regardless of error conditions we need to mark the stream as closed, which 
is better than it being in error and being marked as open. Committing 
again :)
--
dIon Gillard, Multitask Consulting
Work:      http://www.multitask.com.au
Developers: http://adslgateway.multitask.com.au/developers



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message