From 9600a0aa0b1fe0e2bed90234f324bf03797f9c8c Mon Sep 17 00:00:00 2001 From: Steven Post Date: Mon, 18 Mar 2013 16:38:46 +0100 Subject: [PATCH] Test: avoid NPE when zipFile could not be created --- .../java/hudson/util/io/ZipArchiverTest.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/core/src/test/java/hudson/util/io/ZipArchiverTest.java b/core/src/test/java/hudson/util/io/ZipArchiverTest.java index d30adf9a23..ddea8690d8 100644 --- a/core/src/test/java/hudson/util/io/ZipArchiverTest.java +++ b/core/src/test/java/hudson/util/io/ZipArchiverTest.java @@ -65,13 +65,13 @@ public class ZipArchiverTest extends TestCase { } catch (Exception e) { fail("exception driving ZipArchiver", e); } finally { - try { - archiver.close(); - } catch (IOException e) { - // ignored + if (archiver != null) { + try { + archiver.close(); + } catch (IOException e) { + // ignored + } } - - archiver = null; } // examine zip contents and assert that none of the entry names (paths) have @@ -86,10 +86,12 @@ public class ZipArchiverTest extends TestCase { } catch (Exception e) { fail("failure enumerating zip entries", e); } finally { - try { - zipFileVerify.close(); - } catch (IOException e) { - // ignored + if (zipFileVerify != null) { + try { + zipFileVerify.close(); + } catch (IOException e) { + // ignored + } } }