java - Android retrofit unexpected value of 'canceled' flag in 'onFailure()' after cancelling all Requests -


i using latest version of retrofit. performing multiple requests in activity , in ondestroy method, i.e. when activity ends, wish terminate pending requests , hence calling okhttpclient.dispatcher().cancelall().

the onfailure method of request handled in manner :-

        @override         public void onfailure(call<apiresponseclass> call, throwable t) {              if (call != null && !call.iscanceled()) {                 // call not cancelled, handle network failure                  onnetworkfailure(call, t);              } else if (call != null && call.iscanceled()){                  // call cancelled. ignore since cancelled.              }         } 


problem is, i'm receiving unexpected behavior in onfailure method. despite call being cancelled through okhttpclient.dispatcher().cancelall() , canceled flag received false, should have been true, i.e. call.iscancelled() should have been true.

however, variable throwable t surprisingly sending cause java.io.ioexception: canceled , detailmessage canceled . have added screenshot of debugger...

enter image description here

my question is, if cause of exception determined cancellation of request, why isn't canceled flag displaying proper result??

i have been referring link cancelling ongoing retrofit requests...

please help.

despite fact hate answering questions, since nobody answered here, writing in order others facing similar issues.

yes, bug in retrofit library. since nobody responded in stackoverflow, raised same query in official retrofit github repository. can find link issue on here. https://github.com/square/retrofit/issues/2076

this expected fixed in retrofit version v2.2.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -