Skip to content

Commit

Permalink
Fix #973 Make sure all resources are closed
Browse files Browse the repository at this point in the history
Make sure all FileStream and FileLock are closed using AutoClose pattern.
  • Loading branch information
chkuang-g committed Jun 17, 2022
1 parent 05f20ca commit a2718bb
Showing 1 changed file with 0 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,6 @@ public static void writeTokenToInternalStorage(Context context, String token) {
sizeBuffer.order(ByteOrder.LITTLE_ENDIAN);
sizeBuffer.putInt(buffer.length);

// try (FileOutputStream lockFileStream = context.openFileOutput(MessageWriter.LOCK_FILE, 0)) {
// // Acquire lock. This prevents the C++ code from consuming and clearing the file while we
// // append to it.
// try (FileLock lock = lockFileStream.getChannel().lock()) {
// try (FileOutputStream outputStream =
// context.openFileOutput(MessageWriter.STORAGE_FILE, Context.MODE_APPEND)) {
// // We send both the buffer length and the buffer itself so that we can potentially
// // process more than one event in the case where they get queued up.
// outputStream.write(sizeBuffer.array());
// outputStream.write(buffer);
// } catch (Exception e) {
// e.printStackTrace();
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
try (FileOutputStream lockFileStream = context.openFileOutput(MessageWriter.LOCK_FILE, 0);
// Acquire lock. This prevents the C++ code from consuming and clearing the file while we
// append to it.
Expand Down

0 comments on commit a2718bb

Please sign in to comment.