From ad04d90940cae09fc020c7ebd8a183e40603bdfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20Sch=C3=A4fer?= Date: Sun, 6 May 2018 12:35:34 +0200 Subject: [PATCH] fix: exception when trying to close undefined stream in finally block --- modules/helma/Zip.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/helma/Zip.js b/modules/helma/Zip.js index 921fb254..1fdff170 100644 --- a/modules/helma/Zip.js +++ b/modules/helma/Zip.js @@ -17,7 +17,7 @@ /** * @fileoverview Fields and methods of the helma.Zip class. *

- * To use this optional module, its repository needs to be added to the + * To use this optional module, its repository needs to be added to the * application, for example by calling app.addRepository('modules/helma/Zip.js') */ @@ -39,7 +39,7 @@ if (!global.helma) { * path to the .zip file as string. * @constructor * @returns A newly created instance of helma.Zip. - * @author Robert Gaggl + * @author Robert Gaggl */ helma.Zip = function(file) { @@ -85,7 +85,7 @@ helma.Zip = function(file) { var outStream = new java.io.BufferedOutputStream(new java.io.FileOutputStream(dest)); outStream.write(buf, 0, size); } finally { - outStream.close(); + if (outStream) outStream.close(); } } return null; @@ -150,7 +150,7 @@ helma.Zip = function(file) { } return result; }; - + /** * Returns an array containing the entries of the archive * represented by this helma.Zip instance. @@ -225,7 +225,7 @@ helma.Zip = function(file) { * or the path to a file or directory on disk that should be added to the * archive. If the argument represents a directory, its contents will be added * recursively to the archive. - * @param {Number} level An optional compression level to use. The argument + * @param {Number} level An optional compression level to use. The argument * must be between zero and 9 (default: 9 = best compression). * @param {String} pathPrefix An optional path prefix to use within the archive. */ @@ -306,7 +306,7 @@ helma.Zip = function(file) { this.getData = function() { return bOutStream.toByteArray(); }; - + /** * Saves the archive. * @param {String} dest The full destination path including the name @@ -322,7 +322,7 @@ helma.Zip = function(file) { var outStream = new java.io.FileOutputStream(destFile); bOutStream.writeTo(outStream); } finally { - outStream.close(); + if (outStream) outStream.close(); } return; }; @@ -446,7 +446,7 @@ helma.Zip.Entry = function(entry) { /** * The data of the zip entry - * @type ByteArray + * @type ByteArray */ this.data = null;