fluttercommunity / flutter_contacts

Contacts Service - A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
https://pub.dev/packages/contacts_service
MIT License
153 stars 69 forks source link

Fix crash on java.lang.IllegalStateException: Reply already submitted #22

Closed olaray closed 6 years ago

olaray commented 6 years ago

Hey! my first PR ever! (ignore this line :D)

This PR fixes crash issue when contact is returned by the pluggin and seconds later, the stack trace below is thrown.

W/System.err(20136): java.lang.IllegalStateException: Reply already submitted W/System.err(20136): at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:146) W/System.err(20136): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:194) W/System.err(20136): at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.onPostExecute(ContactsServicePlugin.java:135) W/System.err(20136): at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.onPostExecute(ContactsServicePlugin.java:115) W/System.err(20136): at android.os.AsyncTask.finish(AsyncTask.java:667) W/System.err(20136): at android.os.AsyncTask.-wrap1(AsyncTask.java) W/System.err(20136): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684) W/System.err(20136): at android.os.Handler.dispatchMessage(Handler.java:102) W/System.err(20136): at android.os.Looper.loop(Looper.java:154) W/System.err(20136): at android.app.ActivityThread.main(ActivityThread.java:6816) W/System.err(20136): at java.lang.reflect.Method.invoke(Native Method) W/System.err(20136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1563) W/System.err(20136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1451)

clovisnicolas commented 6 years ago

Hello thanks for your PR,

I haven't been able to reproduce the issue : Do you have any idea why the reply is sent twice? Is there a result(something) done twice? I believe it would be better to find out why the reply is sent twice rather than just catching the exception