Bug: NullPointerException when channelState.getLastMessage() is null
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:
- Copy setup from tutorial
- Copy ChannelList section from tutorial
- Run the application
- Observe NPE
Are you still having this issue on 1.10.0?
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
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()'
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