dmfs/oauth2-essentials

NullPointerException when response is empty

Malachiasz opened this issue · 6 comments

Version 0.18

java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
at org.dmfs.rfc3986.encoding.FormEncoded.encoded(FormEncoded.java:140)
at org.dmfs.rfc3986.encoding.FormEncoded.toString(FormEncoded.java:127)
at org.dmfs.rfc3986.encoding.FormEncoded.length(FormEncoded.java:84)
at java.lang.StringBuilder.append(StringBuilder.java:288)
at org.dmfs.rfc3986.encoding.XWwwFormUrlEncoded.toString(XWwwFormUrlEncoded.java:119)
at org.dmfs.httpessentials.entities.TextRequestEntity.lambda$new$0(TextRequestEntity.java:40)
at org.dmfs.httpessentials.entities.-$$Lambda$TextRequestEntity$Z-7MUgUWXmaK6a4JNCeTn-SC_P4.value(lambda)
at org.dmfs.httpessentials.entities.BinaryRequestEntity.contentLength(BinaryRequestEntity.java:60)
at org.dmfs.httpessentials.entities.DelegatingRequestEntity.contentLength(DelegatingRequestEntity.java:54)
at org.dmfs.httpessentials.entities.DelegatingRequestEntity.contentLength(DelegatingRequestEntity.java:54)
at org.dmfs.httpessentials.okhttp.OkHttpRequestBody.contentLength(OkHttpRequestBody.java:49)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:58)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at com.unitedinternet.portal.android.lib.rest.RequestsInterceptor.processHeaders(RequestsInterceptor.java:60)
at com.unitedinternet.portal.android.lib.rest.RequestsInterceptor.intercept(RequestsInterceptor.java:50)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
at okhttp3.RealCall.execute(RealCall.java:92)
at org.dmfs.httpessentials.okhttp.PlainOkHttpExecutor.execute(PlainOkHttpExecutor.java:66)
at org.dmfs.httpessentials.executors.useragent.Branded.execute(Branded.java:53)
at org.dmfs.oauth2.client.BasicOAuth2AuthorizationProvider.accessToken(BasicOAuth2AuthorizationProvider.java:55)
at org.dmfs.oauth2.client.BasicOAuth2Client.accessToken(BasicOAuth2Client.java:71)
at org.dmfs.oauth2.client.grants.TokenRefreshGrant.accessToken(TokenRefreshGrant.java:61)

dmfs commented

Thanks for the report. Please tell me, what exactly means "empty response"? Are we talking about a valid HTTP response or an invalid one? I.e., does it contain a status line and any headers? What's the response code?

It was just a guess that the response was empty. I have only the stacktrace from bug monitoring tool.

Also I want to add that it's fairly common exception: 168k events with 717 users in the last version of our app.

dmfs commented

From looking at the stack trace I guess there was a null refresh token. That might have been caused by the empty responses.

any progress on that?

I have created pull request, but to make it working the library dmfs.uri-toolkit should be released and new version used here