stream-chat-android icon indicating copy to clipboard operation
stream-chat-android copied to clipboard

Bug: NullPointerException when channelState.getLastMessage() is null

Open josheroff-livly opened this issue 7 years ago • 4 comments

The tutorial provided in Stream's documentation instructs the reader to copy the sample code from the tutorial as-is.

When using the sample credentials provided, the lastMessage for the ChannelState object that is returned is null, and causes the line channelState.getLastMessage().setStatus(MessageStatus.RECEIVED); to throw an NPE.

Stacktrace:

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.getstream.sdk.chat.rest.Message.setStatus(com.getstream.sdk.chat.enums.MessageStatus)' on a null object reference at com.getstream.sdk.chat.rest.core.Client$3$1.onResponse(Client.java:470) at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run(ExecutorCallAdapterFactory.java:71) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Dependency: `com.github.getstream:stream-chat-android:1.9.1'

Steps to Reproduce:

  1. Copy setup from tutorial
  2. Copy ChannelList section from tutorial
  3. Run the application
  4. Observe NPE

josheroff-livly avatar Sep 23 '19 14:09 josheroff-livly

Are you still having this issue on 1.10.0?

tschellenbach avatar Sep 23 '19 23:09 tschellenbach

Yes, I still saw it in 1.10.0. The sample credentials in the tutorial have changed since I posted this issue and I don't see the crash with those new credentials, though I'd imagine the code is still subject to the same NPE highlighted by PR #58

josheroff-livly avatar Sep 24 '19 14:09 josheroff-livly

I'm seeing this issue in version 3.0.0. java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Date com.getstream.sdk.chat.rest.Message.getDeletedAt()'

Chikrix avatar Oct 23 '19 00:10 Chikrix

I'm seeing this issue in version 3.0.0. java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Date com.getstream.sdk.chat.rest.Message.getDeletedAt()'

Please try new version 3.0.1

adrian09h avatar Oct 23 '19 07:10 adrian09h