Skip to content

Commit

Permalink
Fixes detected file handle leaks
Browse files Browse the repository at this point in the history
Signed-off-by: Olasoji Denloye <olasoji.denloye@intel.com>
  • Loading branch information
asonje committed Jul 25, 2023
1 parent 0dc4568 commit 3de05e1
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,31 @@ public final class CryptoDirectory extends NIOFSDirectory {
}

private void storeWrappedKey(byte[] wrappedKey) {
IndexOutput out = null;
try {
IndexOutput out = super.createOutput("keyfile", new IOContext());
out = super.createOutput("keyfile", new IOContext());
out.writeInt(wrappedKey.length);
out.writeBytes(wrappedKey, 0, wrappedKey.length);
out.close();
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (out != null) IOUtils.closeWhileHandlingException(out);
}
}

private byte[] getWrappedKey() {
IndexInput in = null;
try {
IndexInput in = super.openInput("keyfile", new IOContext());
in = super.openInput("keyfile", new IOContext());
int size = in.readInt();
byte[] ret = new byte[size];
in.readBytes(ret, 0, size);
return ret;
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (in != null) IOUtils.closeWhileHandlingException(in);
}
}

Expand Down

0 comments on commit 3de05e1

Please sign in to comment.