Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE #99

Closed
1 of 3 tasks
pixnbit opened this issue Jul 16, 2016 · 4 comments
Closed
1 of 3 tasks

NPE #99

pixnbit opened this issue Jul 16, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@pixnbit
Copy link

pixnbit commented Jul 16, 2016

                                                                        Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
                                                                           at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:772)
                                                                           at org.eclipse.paho.android.service.MqttService.getConnection(MqttService.java:560)
                                                                           at org.eclipse.paho.android.service.MqttService.isConnected(MqttService.java:407)
                                                                           at org.eclipse.paho.android.service.MqttAndroidClient.isConnected(MqttAndroidClient.java:245)

Please fill out the form below before submitting, thank you!

  • Bug exists Release Version 1.1.0 (Java Repository Master Branch)
  • Bug exists in Snapshot Version 1.1.1-SNAPSHOT (Android Service Repository Master Branch)
  • Bug is just in the Sample Application.

Android API Version Bug Seen on:

Android Version Bug Seen on:

Please also check that if you have found the bug in the Release version (1.1.0) that you check that it also exists in the Snapshot (1.1.1-SNAPSHOT) before raising a bug.

Description of Bug:

E.g. Steps to re-create, how often does this happen etc..

Console Log output (if available):

@jpwsutton jpwsutton added the bug label Jul 18, 2016
@jpwsutton jpwsutton added this to the 1.3.0 milestone Jul 18, 2016
@jpwsutton jpwsutton self-assigned this Jul 18, 2016
@jpwsutton
Copy link
Member

@laoyang Are you able to duplicate this in the SNAPSHOT build? And do you have any steps to recreate?

@jpwsutton jpwsutton mentioned this issue Feb 20, 2017
1 task
@jpwsutton
Copy link
Member

jpwsutton commented Nov 15, 2017

Closing as no response since 2016. Though It looks like the cause of this was that the clientHandle was null when attempting to get the connection, PR #263 adds a null check which will return a more human readable error in this scenario.

@Raja-Raman
Copy link

I observe this crash consistently as of July 2018:
Please suggest any work around.

Android SDK version 26, target version 26.

MqttAndroidClient client;
client.connect(..);
// do stuff
client.disconnect();
if (client==null)
return;
if (client.isConnected()) { /* crashes here */
// do stuff
}

The error message is:
07-13 23:45:53.445 5565-5565/com.raja.mqttsms1 W/System.err: java.lang.NullPointerException: Attempt to
invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:772)
at org.eclipse.paho.android.service.MqttService.getConnection(MqttService.java:560)
at org.eclipse.paho.android.service.MqttService.isConnected(MqttService.java:407)
at org.eclipse.paho.android.service.MqttAndroidClient.isConnected(MqttAndroidClient.java:245)
at com.raja.mqttsms1.MainActivity.connect(MainActivity.java:97)
at com.raja.mqttsms1.MainActivity.onResume(MainActivity.java:293)

@wv1124
Copy link

wv1124 commented Apr 24, 2024

I observe this crash consistently as of July 2018: Please suggest any work around.

Android SDK version 26, target version 26.

MqttAndroidClient client; client.connect(..); // do stuff client.disconnect(); if (client==null) return; if (client.isConnected()) { /* crashes here */ // do stuff }

The error message is: 07-13 23:45:53.445 5565-5565/com.raja.mqttsms1 W/System.err: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Object.hashCode()' on a null object reference at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:772) at org.eclipse.paho.android.service.MqttService.getConnection(MqttService.java:560) at org.eclipse.paho.android.service.MqttService.isConnected(MqttService.java:407) at org.eclipse.paho.android.service.MqttAndroidClient.isConnected(MqttAndroidClient.java:245) at com.raja.mqttsms1.MainActivity.connect(MainActivity.java:97) at com.raja.mqttsms1.MainActivity.onResume(MainActivity.java:293)

when disconect:

                mMqttClient.unsubscribe(this.topic);

// mMqttClient.disconnect();
mMqttClient.close();
mMqttClient.unregisterResources();
mMqttClient = null;
then isConnected() will not throw Invalid ClientHandle Exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants