sacOO7 / socketcluster-client-java

Native java and android client for socketcluster framework in node.js
http://socketcluster.io/
Apache License 2.0
94 stars 42 forks source link

NullPointerException when calling disconnect on socket object with unlimited reconnections #11

Closed nagamanojv closed 7 years ago

nagamanojv commented 7 years ago

I have initialized the socket and set the reconnection strategy as follows socket.setReconnection(new ReconnectStrategy()); Now, if I call socket.disconnect() when connection is active, then there is no issue. But if I call the disconnect() method when the connection was broken and reconnection loop is triggered the app is crashing with NullPointerException in reconnect() method.

As I understand the scenario, as soon as connection to the server is broken it initiates a reconnection loop. There is a null check before calling the reconnect() method but no check in the TimerTask. If the disconnect() method is called on the socket object , it will set the strategy to null and when the TimerTask is executed after scheduled time, it is crashing with NullPointerException

I have forked the repo, added a null check in the TimerTask. It is now working without crashing.

sacOO7 commented 7 years ago

Then try to create a new pull request, I will merge your changes. Star the repo. if possible :p

nagamanojv commented 7 years ago

Pull request created. Repo already starred :)