Skip to content

Commit a2718bb

Browse files
committed
Fix #973 Make sure all resources are closed
Make sure all FileStream and FileLock are closed using AutoClose pattern.
1 parent 05f20ca commit a2718bb

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

messaging/src/android/java/com/google/firebase/messaging/cpp/RegistrationIntentService.java

-19
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,6 @@ public static void writeTokenToInternalStorage(Context context, String token) {
6767
sizeBuffer.order(ByteOrder.LITTLE_ENDIAN);
6868
sizeBuffer.putInt(buffer.length);
6969

70-
// try (FileOutputStream lockFileStream = context.openFileOutput(MessageWriter.LOCK_FILE, 0)) {
71-
// // Acquire lock. This prevents the C++ code from consuming and clearing the file while we
72-
// // append to it.
73-
// try (FileLock lock = lockFileStream.getChannel().lock()) {
74-
// try (FileOutputStream outputStream =
75-
// context.openFileOutput(MessageWriter.STORAGE_FILE, Context.MODE_APPEND)) {
76-
// // We send both the buffer length and the buffer itself so that we can potentially
77-
// // process more than one event in the case where they get queued up.
78-
// outputStream.write(sizeBuffer.array());
79-
// outputStream.write(buffer);
80-
// } catch (Exception e) {
81-
// e.printStackTrace();
82-
// }
83-
// } catch (Exception e) {
84-
// e.printStackTrace();
85-
// }
86-
// } catch (Exception e) {
87-
// e.printStackTrace();
88-
// }
8970
try (FileOutputStream lockFileStream = context.openFileOutput(MessageWriter.LOCK_FILE, 0);
9071
// Acquire lock. This prevents the C++ code from consuming and clearing the file while we
9172
// append to it.

0 commit comments

Comments
 (0)