Android Question OkHttpClientWrapper null object reference

JDS

Active Member
Licensed User
Longtime User
We use Firebase in our app(s) so we can monitor errors that users have experienced.

Sometimes we get the error below. We can't get it reproduced.

Attempt to write to field 'anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpResponse lmmobile.jds.android.httpjob._response' on a null object reference

Any idea how we can prevent this from happening?
 

JDS

Active Member
Licensed User
Longtime User
Sorry, very busy morning...

Fatal Exception: java.lang.NullPointerException: Attempt to write to field 'anywheresoftware.b4h.okhttp.OkHttpClientWrapper$OkHttpResponse lmmobile.jds.android.httpjob._response' on a null object reference
at lmmobile.jds.android.httputils2service._hc_responseerror(httputils2service.java:209)
at java.lang.reflect.Method.invoke(Method.java)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)


OkHttp ConnectionPool
at java.lang.Object.wait(Object.java)
at okhttp3.ConnectionPool$1.run(ConnectionPool.java:65)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
 
Upvote 0

JDS

Active Member
Licensed User
Longtime User
The threading library isn't used.
OkHTTP and OkHttpUtils2 are used.

Problem is that we don't know which call us causing the error.
 
Upvote 0

JDS

Active Member
Licensed User
Longtime User
I guess so.
OkHTTP is version 1.22
OkHttpUtils2 is version 2.91


I'm using B4A 9.80
 
Upvote 0

JDS

Active Member
Licensed User
Longtime User
Are you directly accessing HttpUtils2Service.hc ?
No we're not accessing it directly. Only by soap/json

like
B4X:
Soap.Initialize("PutGPS",Me)
Soap.PostString(Globaal.MainRESTUrl&"PutGPS",sParameter.Replace("[","").Replace("]",""))
Soap.GetRequest.SetHeader("lmmobile",Globaal.PDAID.Trim)
Soap.GetRequest.SetHeader("wachtwoord",Globaal.wachtwoord.Trim)
Soap.GetRequest.SetHeader("Content-Type", "application/json")

or

B4X:
sParameter = File.ReadString(Globaal.Map_ChangeVal,sNewFile)
sParameter = Globaal.String2Base64(sParameter)
sParameter = sParameter.Replace(" " ,"+")
If (iWait=0) Then
  Soap.Initialize("PutChangeChauffeurKenteken","GlobalService")
Else
  Soap.Initialize("PutChangeChauffeurKenteken",Me)
End If
                
requestSoapXML = Globaal.MainUrl&"/PutChangeChauffeurKenteken/JSON?iPDA="&Globaal.PDAID&"&sWachtwoord="&Globaal.wachtwoord&"&sXML="&sParameter
Soap.Download(requestSoapXML)
 
Upvote 0
Top