Skip to content

Commit

Permalink
Added try-with-resources for input stream
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astachowski committed Nov 7, 2024
1 parent f53ba90 commit a4a5d32
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/test/java/net/snowflake/client/core/IncidentUtilLatestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ public void testDumpVmMetrics() throws IOException {
EventUtil.getDumpPathPrefix() + "/" + INC_DUMP_FILE_NAME + incidentId + INC_DUMP_FILE_EXT;

// Read back the file contents
GZIPInputStream gzip = new GZIPInputStream(new FileInputStream(targetVMFileLocation));
StringWriter sWriter = new StringWriter();
IOUtils.copy(gzip, sWriter, "UTF-8");
String output = sWriter.toString();
assertEquals(
"\n\n\n--------------------------- METRICS " + "---------------------------\n\n",
output.substring(0, 69));
sWriter.close();
try (FileInputStream fis = new FileInputStream(targetVMFileLocation)) {
GZIPInputStream gzip = new GZIPInputStream(fis);
StringWriter sWriter = new StringWriter();
IOUtils.copy(gzip, sWriter, "UTF-8");
String output = sWriter.toString();
assertEquals(
"\n\n\n--------------------------- METRICS " + "---------------------------\n\n",
output.substring(0, 69));
sWriter.close();
}
}
}

0 comments on commit a4a5d32

Please sign in to comment.