Skip to content

Commit

Permalink
ctf: Fix FileOutputStream leak in LttngTraceGenerator
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
  • Loading branch information
PatrickTasse committed May 21, 2024
1 parent b35c9e2 commit 0dd5e89
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2013, 2017 Ericsson
* Copyright (c) 2013, 2024 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -275,13 +275,13 @@ public void writeTrace(File file) {
file.mkdir();

File metadataFile = new File(file.getPath() + File.separator + "metadata");
File[] streams = new File[fNbChans];
FileOutputStream[] streams = new FileOutputStream[fNbChans];
FileChannel[] channels = new FileChannel[fNbChans];

try {
for (int i = 0; i < fNbChans; i++) {
streams[i] = new File(file.getPath() + File.separator + "channel" + i);
channels[i] = new FileOutputStream(streams[i]).getChannel();
streams[i] = new FileOutputStream(new File(file.getPath() + File.separator + "channel" + i));
channels[i] = streams[i].getChannel();
}
} catch (FileNotFoundException e) {
}
Expand Down Expand Up @@ -371,7 +371,7 @@ public void writeTrace(File file) {
}
writeToDisk(channels, chan, bb);
try {
channels[chan].close();
streams[chan].close();
} catch (IOException e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 0dd5e89

Please sign in to comment.