Skip to content

Fix #973 Make sure all resources are closed in RegistrationIntentService #998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,19 @@ public static void writeTokenToInternalStorage(Context context, String token) {
// Write out the buffer length into the first four bytes.
sizeBuffer.order(ByteOrder.LITTLE_ENDIAN);
sizeBuffer.putInt(buffer.length);
FileLock lock = null;
try {
// Acquire lock. This prevents the C++ code from consuming and clearing the file while we
// append to it.
FileOutputStream lockFileStream = context.openFileOutput(MessageWriter.LOCK_FILE, 0);
lock = lockFileStream.getChannel().lock();

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.
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.
FileLock lock = lockFileStream.getChannel().lock();
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);
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
// Release the lock.
try {
if (lock != null) {
lock.release();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Expand Down
22 changes: 12 additions & 10 deletions release_build_files/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,23 @@ All Firebase SDKs | platform(com.google.firebase:firebase-bom:30.0.0)
| | (Android Bill of Materials)
Firebase AdMob | libfirebase_admob.a
| | libfirebase_app.a
| | com.google.firebase:firebase-analytics
| | com.google.firebase:firebase-analytics
| | (Maven package)
| | com.google.firebase:firebase-ads:19.8.0
| | com.google.firebase:firebase-ads:19.8.0
| | (Maven package)
Firebase Analytics | libfirebase_analytics.a
| | libfirebase_app.a
| | com.google.firebase:firebase-analytics
| | com.google.firebase:firebase-analytics
| | (Maven package)
Firebase Authentication | libfirebase_auth.a
| | libfirebase_app.a
| | com.google.firebase:firebase-analytics
| | com.google.firebase:firebase-analytics
| | (Maven package)
| | com.google.firebase:firebase-auth
| | com.google.firebase:firebase-auth
| | (Maven package)
Firebase Dynamic Links | libfirebase_dynamic_links.a
| | libfirebase_app.a
| | com.google.firebase:firebase-analytics
| | com.google.firebase:firebase-analytics
| | (Maven package)
| | com.google.firebase:firebase-dynamic-links
| | (Maven package)
Expand Down Expand Up @@ -156,7 +156,7 @@ Firebase Storage | libfirebase_storage.a
| | (Maven package)
| | com.google.firebase:firebase-auth
| | (Maven package)
Google Play services module| com.google.android.gms:play-services-base:18.0.1
Google Play services module| com.google.android.gms:play-services-base:18.0.1
| | (Maven package)

The Firebase C++ SDK uses an Android BoM (Bill of Materials) to specify a single
Expand Down Expand Up @@ -615,6 +615,8 @@ code.
- Changes
- General (Android): Switched over to Android BoM (Bill of Materials)
for dependency versions. This requires Gradle 5.
- Messaging (Android): Fixed #973. Make sure all the resources are closed in
`RegistrationIntentService`.

### 9.1.0
- Changes
Expand Down Expand Up @@ -710,16 +712,16 @@ code.
and include support for ARM-based Mac systems.
- General (iOS): iOS SDKs are now built using Xcode 12.2.
- Messaging (Android): Fixes an issue to receive token when
initialize the app.
initialize the app.
([#667](https://github.com/firebase/firebase-cpp-sdk/pull/667)).
- Auth (Desktop): Fix a crash that would occur if parsing the JSON
response from the server failed
([#692](https://github.com/firebase/firebase-cpp-sdk/pull/692)).

### 8.5.0
- Changes
- General: Updating Android and iOS dependencies to the latest.
- General: Fixes an issue with generating Proguard files.
- General: Fixes an issue with generating Proguard files.
([#664](https://github.com/firebase/firebase-cpp-sdk/pull/664)).

### 8.4.0
Expand Down