commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r674306 - in /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress: archivers/tar/TarArchive.java archivers/zip/ZipArchive.java compressors/bzip2/BZip2Compressor.java
Date Sun, 06 Jul 2008 15:18:32 GMT
Author: sebb
Date: Sun Jul  6 08:18:31 2008
New Revision: 674306

URL: http://svn.apache.org/viewvc?rev=674306&view=rev
Log:
Null checks before closing files

Modified:
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Compressor.java

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java?rev=674306&r1=674305&r2=674306&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/tar/TarArchive.java
Sun Jul  6 08:18:31 2008
@@ -107,7 +107,8 @@
 					}
 					destination.flush();
 				} finally {
-					destination.close();
+					if (destination != null)
+					    destination.close();
 				}
 			}
 		} catch(IOException e) {
@@ -165,7 +166,9 @@
 			throw new ArchiveException("Creation of this archive failed cause of IOExceptions.", e);
 		} finally {
 			try {
-				out.close();
+				if (out != null) {
+				    out.close();
+				}
 			} catch (IOException e1) {
 				throw new ArchiveException("Creation of this archive failed cause of IOExceptions.",
e1);
 			}

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java?rev=674306&r1=674305&r2=674306&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/archivers/zip/ZipArchive.java
Sun Jul  6 08:18:31 2008
@@ -101,7 +101,9 @@
 			throw new UnpackException("Exception while unpacking.", e);
 		} finally {
 			try {
-				zInputStream.close();
+				if (zInputStream != null){
+				    zInputStream.close();
+				}
 			} catch (IOException e1) {
 				throw new UnpackException("Exception while unpacking.", e1);
 			}
@@ -147,7 +149,9 @@
 			throw new ArchiveException("Creation of this archive failed cause of IOExceptions.", e);
 		} finally {
 			try {
-				out.close();
+				if (out != null){
+				    out.close();
+				}
 			} catch (IOException e1) {
 				throw new ArchiveException("Creation of this archive failed cause of IOExceptions.",
e1);
 			}

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Compressor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Compressor.java?rev=674306&r1=674305&r2=674306&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Compressor.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/compressors/bzip2/BZip2Compressor.java
Sun Jul  6 08:18:31 2008
@@ -60,7 +60,9 @@
 			throw new CompressException("An IO Exception occured", e);
 		} finally {
 			try {
-				outputBZStream.close();
+				if (outputBZStream != null){
+				    outputBZStream.close();
+				}
 			} catch (IOException e1) {
 				throw new CompressException("An IO Exception occured while closing the streams", e1);
 			}



Mime
View raw message