Skip to content

Commit

Permalink
CSB-6387 Close streams noted as resource leaks from OpenScanHub resul…
Browse files Browse the repository at this point in the history
…ts (#504)

* CSB-6387 Close streams noted as resource leaks from OpenScanHub results

* Change closes to try with resources
  • Loading branch information
cunningt authored Feb 4, 2025
1 parent 5ca99c0 commit 193a1c6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ public class RequiredProductizedArtifactsReader {
public static HashMap<String, Boolean> getProductizedCSBArtifacts(File requiredFile) {
HashMap<String, Boolean> map = new HashMap<>();

try {
FileReader fileReader = new FileReader(requiredFile);
BufferedReader br = new BufferedReader(fileReader);
try (FileReader fileReader = new FileReader(requiredFile);
BufferedReader br = new BufferedReader(fileReader)) {

String line;
while ((line = br.readLine()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public static File unpackPatchRepository(File zipFile) throws MavenExecutionExce
throw new MavenExecutionException("Can't create temporary directory to unzip " + zipFile, e);
}

try {
ZipFile zf = new ZipFile(zipFile);
try (ZipFile zf = new ZipFile(zipFile)) {
byte[] buf = new byte[16384];
for (Enumeration<? extends ZipEntry> e = zf.entries(); e.hasMoreElements(); ) {
ZipEntry ze = e.nextElement();
Expand Down

0 comments on commit 193a1c6

Please sign in to comment.