You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2008/07/05 20:45:40 UTC

svn commit: r674223 - /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java

Author: bayard
Date: Sat Jul  5 11:45:40 2008
New Revision: 674223

URL: http://svn.apache.org/viewvc?rev=674223&view=rev
Log:
Null protect the stream closing

Modified:
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java?rev=674223&r1=674222&r2=674223&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java (original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Sat Jul  5 11:45:40 2008
@@ -61,8 +61,12 @@
 			throw new CompressException("An IO Exception has occured", e);
 		} finally {
 			try {
-				tempFileOutputStream.close();
-				outputStream.close();
+                if(tempFileOutputStream != null) {
+    				tempFileOutputStream.close();
+                }
+                if(outputStream != null) {
+    				outputStream.close();
+                }
 			} catch (IOException e) {
 				throw new CompressException("An IO Exception occured while closing the streams", e);
 			}



Re: svn commit: r674223 - /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java

Posted by sebb <se...@gmail.com>.
Yes, OK now

On 06/07/2008, Henri Yandell <fl...@gmail.com> wrote:
> Should be fixed.
>
>
>  On Sat, Jul 5, 2008 at 3:26 PM, sebb <se...@gmail.com> wrote:
>  > On 05/07/2008, sebb <se...@gmail.com> wrote:
>  >> On 05/07/2008, bayard@apache.org <ba...@apache.org> wrote:
>  >>  > Author: bayard
>  >>  >  Date: Sat Jul  5 11:45:40 2008
>  >>  >  New Revision: 674223
>  >>  >
>  >>  >  URL: http://svn.apache.org/viewvc?rev=674223&view=rev
>  >>  >  Log:
>  >>  >  Null protect the stream closing
>  >>  >
>  >>  >  Modified:
>  >>  >     commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>  >>  >
>  >>  >  Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>  >>  >  URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java?rev=674223&r1=674222&r2=674223&view=diff
>  >>  >  ==============================================================================
>  >>  >  --- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java (original)
>  >>  >  +++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Sat Jul  5 11:45:40 2008
>  >>  >  @@ -61,8 +61,12 @@
>  >>  >                         throw new CompressException("An IO Exception has occured", e);
>  >>  >                 } finally {
>  >>  >                         try {
>  >>  >  -                               tempFileOutputStream.close();
>  >>  >  -                               outputStream.close();
>  >>  >  +                if(tempFileOutputStream != null) {
>  >>  >  +                               tempFileOutputStream.close();
>  >>  >  +                }
>  >>  >  +                if(outputStream != null) {
>  >>  >  +                               outputStream.close();
>  >>  >  +                }
>  >>
>  >>
>  >> However, if the first close() throws an IOException, the second will
>  >>  be skipped ;-)
>  >>
>  >
>  > Actually, Findbugs points out that outputStream is always null at that point ;-)
>  >
>  > Looks like the method is incomplete.
>  >
>  >>
>  >>  >                         } catch (IOException e) {
>  >>  >                                 throw new CompressException("An IO Exception occured while closing the streams", e);
>  >>  >                         }
>  >>  >
>  >>  >
>  >>  >
>  >>
>  >
>
> > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  > For additional commands, e-mail: dev-help@commons.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>  For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Re: svn commit: r674223 - /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java

Posted by Henri Yandell <fl...@gmail.com>.
Should be fixed.

On Sat, Jul 5, 2008 at 3:26 PM, sebb <se...@gmail.com> wrote:
> On 05/07/2008, sebb <se...@gmail.com> wrote:
>> On 05/07/2008, bayard@apache.org <ba...@apache.org> wrote:
>>  > Author: bayard
>>  >  Date: Sat Jul  5 11:45:40 2008
>>  >  New Revision: 674223
>>  >
>>  >  URL: http://svn.apache.org/viewvc?rev=674223&view=rev
>>  >  Log:
>>  >  Null protect the stream closing
>>  >
>>  >  Modified:
>>  >     commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>>  >
>>  >  Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>>  >  URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java?rev=674223&r1=674222&r2=674223&view=diff
>>  >  ==============================================================================
>>  >  --- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java (original)
>>  >  +++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Sat Jul  5 11:45:40 2008
>>  >  @@ -61,8 +61,12 @@
>>  >                         throw new CompressException("An IO Exception has occured", e);
>>  >                 } finally {
>>  >                         try {
>>  >  -                               tempFileOutputStream.close();
>>  >  -                               outputStream.close();
>>  >  +                if(tempFileOutputStream != null) {
>>  >  +                               tempFileOutputStream.close();
>>  >  +                }
>>  >  +                if(outputStream != null) {
>>  >  +                               outputStream.close();
>>  >  +                }
>>
>>
>> However, if the first close() throws an IOException, the second will
>>  be skipped ;-)
>>
>
> Actually, Findbugs points out that outputStream is always null at that point ;-)
>
> Looks like the method is incomplete.
>
>>
>>  >                         } catch (IOException e) {
>>  >                                 throw new CompressException("An IO Exception occured while closing the streams", e);
>>  >                         }
>>  >
>>  >
>>  >
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Re: svn commit: r674223 - /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java

Posted by sebb <se...@gmail.com>.
On 05/07/2008, sebb <se...@gmail.com> wrote:
> On 05/07/2008, bayard@apache.org <ba...@apache.org> wrote:
>  > Author: bayard
>  >  Date: Sat Jul  5 11:45:40 2008
>  >  New Revision: 674223
>  >
>  >  URL: http://svn.apache.org/viewvc?rev=674223&view=rev
>  >  Log:
>  >  Null protect the stream closing
>  >
>  >  Modified:
>  >     commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>  >
>  >  Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>  >  URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java?rev=674223&r1=674222&r2=674223&view=diff
>  >  ==============================================================================
>  >  --- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java (original)
>  >  +++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Sat Jul  5 11:45:40 2008
>  >  @@ -61,8 +61,12 @@
>  >                         throw new CompressException("An IO Exception has occured", e);
>  >                 } finally {
>  >                         try {
>  >  -                               tempFileOutputStream.close();
>  >  -                               outputStream.close();
>  >  +                if(tempFileOutputStream != null) {
>  >  +                               tempFileOutputStream.close();
>  >  +                }
>  >  +                if(outputStream != null) {
>  >  +                               outputStream.close();
>  >  +                }
>
>
> However, if the first close() throws an IOException, the second will
>  be skipped ;-)
>

Actually, Findbugs points out that outputStream is always null at that point ;-)

Looks like the method is incomplete.

>
>  >                         } catch (IOException e) {
>  >                                 throw new CompressException("An IO Exception occured while closing the streams", e);
>  >                         }
>  >
>  >
>  >
>

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


Re: svn commit: r674223 - /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java

Posted by sebb <se...@gmail.com>.
On 05/07/2008, bayard@apache.org <ba...@apache.org> wrote:
> Author: bayard
>  Date: Sat Jul  5 11:45:40 2008
>  New Revision: 674223
>
>  URL: http://svn.apache.org/viewvc?rev=674223&view=rev
>  Log:
>  Null protect the stream closing
>
>  Modified:
>     commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>
>  Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java
>  URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java?rev=674223&r1=674222&r2=674223&view=diff
>  ==============================================================================
>  --- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java (original)
>  +++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/AbstractCompressor.java Sat Jul  5 11:45:40 2008
>  @@ -61,8 +61,12 @@
>                         throw new CompressException("An IO Exception has occured", e);
>                 } finally {
>                         try {
>  -                               tempFileOutputStream.close();
>  -                               outputStream.close();
>  +                if(tempFileOutputStream != null) {
>  +                               tempFileOutputStream.close();
>  +                }
>  +                if(outputStream != null) {
>  +                               outputStream.close();
>  +                }

However, if the first close() throws an IOException, the second will
be skipped ;-)

>                         } catch (IOException e) {
>                                 throw new CompressException("An IO Exception occured while closing the streams", e);
>                         }
>
>
>

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