From 6cc9804280ee670547d29887f73d660abf3a847d Mon Sep 17 00:00:00 2001 From: stevejagodzinski Date: Mon, 25 Oct 2021 05:08:51 -0400 Subject: [PATCH] Explicit null checking --- src/test/java/TestUtil.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/java/TestUtil.java b/src/test/java/TestUtil.java index 72ba83f9..328a675d 100644 --- a/src/test/java/TestUtil.java +++ b/src/test/java/TestUtil.java @@ -369,8 +369,8 @@ public static void verifyOneAndOnlyOneEventSentToSplunk(String msg) throws IOExc break; } - resultsReader.close(); - resultsStream.close(); + Objects.requireNonNull(resultsReader, "resultsReader must not be null").close(); + Objects.requireNonNull(resultsStream, "resultsStream must not be null").close(); Assert.assertTrue(eventCount == 1); } @@ -399,8 +399,8 @@ public static void verifyNoEventSentToSplunk(List msgs) throws IOExcepti break; } - resultsReader.close(); - resultsStream.close(); + Objects.requireNonNull(resultsReader, "resultsReader must not be null").close(); + Objects.requireNonNull(resultsStream, "resultsStream must not be null").close(); Assert.assertTrue(eventCount == 0); } @@ -444,8 +444,8 @@ public static void verifyEventsSentToSplunk(List msgs) throws IOExceptio Thread.sleep(5000); } - resultsReader.close(); - resultsStream.close(); + Objects.requireNonNull(resultsReader, "resultsReader must not be null").close(); + Objects.requireNonNull(resultsStream, "resultsStream must not be null").close(); Assert.assertEquals("Event search results did not match.", 1, eventCount); } @@ -496,8 +496,8 @@ public static void verifyEventsSentInOrder(String prefix, int totalEventsCount, break; } - resultsReader.close(); - resultsStream.close(); + Objects.requireNonNull(resultsReader, "resultsReader must not be null").close(); + Objects.requireNonNull(resultsStream, "resultsStream must not be null").close(); assert (results.size() == totalEventsCount) : String.format("expect: %d, actual: %d", totalEventsCount, results.size());