-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[cloud_firestore] Fix possible NullPointerException #31
[cloud_firestore] Fix possible NullPointerException #31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you removed all the AsyncTask
calls here and I think that those are necessary so I would be surprised if this works.
I'm seeing integration test failures on Android (note: the Flutterfire CI only runs integration tests on iOS right now but I'm working on fixing that)
Can we keep the AsyncTask
part but call result.success() on the original thread?
jackson-macbookpro4:example jackson$ flutter drive test_driver/cloud_firestore.dart
Found multiple connected devices:
Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
iPhone X • 10EBB3FA-C04F-44EA-804B-52DD0C08AC50 • ios • iOS 12.1 (simulator)
Using device Android SDK built for x86.
Starting application: test_driver/cloud_firestore.dart
Initializing gradle... 0.8s
Resolving dependencies... 1.6s
"build/app/outputs/apk/app.apk" does not exist.
ERROR: [TAG] Failed to resolve variable '${junit.version}'
ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'
warning: unknown enum constant Scope.LIBRARY_GROUP
reason: class file for android.support.annotation.RestrictTo$Scope not found
warning: unknown enum constant Scope.LIBRARY_GROUP
warning: unknown enum constant Scope.LIBRARY_GROUP
Note: /Users/jackson/git/plugins_flutterfire/packages/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/jackson/git/plugins_flutterfire/packages/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 warnings
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 35.8s
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk... 2.4s
I/flutter ( 6004): Observatory listening on http://127.0.0.1:39831/sWZuJW6jnNw=/
[info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:59154/sWZuJW6jnNw=/
[trace] FlutterDriver: Isolate found with number: 1242708047141067
[trace] FlutterDriver: Isolate is paused at start.
[trace] FlutterDriver: Attempting to resume isolate
[trace] FlutterDriver: Waiting for service extension
I/flutter ( 6004): 00:00 +0: Firestore getDocumentsWithFirestoreSettings
[info ] FlutterDriver: Connected to Flutter application.
I/flutter ( 6004): 00:00 +1: Firestore getDocumentsFromCollection
I/flutter ( 6004): 00:01 +2: Firestore getDocumentsFromCollectionGroup
I/flutter ( 6004): 00:01 +3: Firestore increment
I/flutter ( 6004): 00:03 +4: Firestore includeMetadataChanges
I/flutter ( 6004): 00:03 +5: Firestore runTransaction
[warning] FlutterDriver: Instance of '_WebSocketImpl' is closed with an unexpected code 1005
[warning] FlutterDriver: Instance of '_WebSocketImpl' is closed with an unexpected code 1005
[warning] FlutterDriver: request_data message is taking a long time to complete...
Stopping application instance.
@@ -419,7 +423,7 @@ public void notImplemented() { | |||
// Wait till transaction is complete. | |||
try { | |||
String timeoutKey = "transactionTimeout"; | |||
long timeout = ((Number) arguments.get(timeoutKey)).longValue(); | |||
Long timeout = call.argument(timeoutKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this surprising, I would expect that you'd need to call longValue
here if an int
was passed from Dart. Are you sure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it should work.
If you look here you can see that a dart int
can fit a java Long
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, I tested. It broke. Moving to Integer solves.
@collinjackson there is no documentation in cloud firestore saying that we need to offload the actions to another thread. With my experience using firebase in android, that is never the case, as any work that need to be in a separated thread is executed with |
@collinjackson I partly understood the problem. |
I am closing this PR as I am not able to keep it updated. |
Description
Removed Activity Reference from plugin to avoid possible NullPointerException.
AsyncTasks are not needed to run Transactions, however transactions are not guaranteed run in UI Thread so the Handler is still needed to send data to Dart.
Related Issues
flutter/flutter#38692
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?