Skip to content

Handle some Exceptions caused eg. by missing network during shutdown#342

Merged
devgianlu merged 4 commits intolibrespot-org:devfrom
funtax:Handle_Exceptions_during_shutdown
Apr 21, 2021
Merged

Handle some Exceptions caused eg. by missing network during shutdown#342
devgianlu merged 4 commits intolibrespot-org:devfrom
funtax:Handle_Exceptions_during_shutdown

Conversation

@funtax
Copy link
Contributor

@funtax funtax commented Apr 21, 2021

If you close the player for example during missing network or while a reconnect is in progress, some issues might occur and cause uncaught Exceptions.
This PR fixes the most occurring issues.

This might especially be required if you use librespot-java on a mobile client like Android.

@devgianlu
Copy link
Member

I should have a look at fixing this at the source instead of catching the exceptions afterwards.

@funtax
Copy link
Contributor Author

funtax commented Apr 21, 2021

This would be of course the best solution. Might be a little bit complicated to reproduce. It's a mix between "disconnect network" and closing the player+session. An often happening situation on mobile devices and will likely also affect the new Android-project of librespot-java.

@devgianlu
Copy link
Member

I remember having dealt with that before, having a closer look now.

@devgianlu
Copy link
Member

@funtax Do you have stacktraces for those NullPointerExceptions? I cannot keep them

@funtax
Copy link
Contributor Author

funtax commented Apr 21, 2021

They might be useless because they happen at another position now and are extracted from "Android Vitals".
I think it was with player-1.5.5, then I internally updated my custom version of librespot-java.
But maybe you can reproduce the situation:

java.lang.NullPointerException:
at xyz.gianlu.librespot.core.Session.reconnect (Session.java:671)
at xyz.gianlu.librespot.core.Session.access$1100 (Session.java:60)
at xyz.gianlu.librespot.core.Session$Receiver.run (Session.java:1295)
at java.lang.Thread.run (Thread.java:929)

java.lang.NullPointerException:
at xyz.gianlu.librespot.core.Session.connect (Session.java:299)
at xyz.gianlu.librespot.core.Session.reconnect (Session.java:669)
at xyz.gianlu.librespot.core.Session.access$1100 (Session.java:60)
at xyz.gianlu.librespot.core.Session$Receiver.run (Session.java:1295)
at java.lang.Thread.run (Thread.java:929)

And the one within sendUnchecked() might be triggered by "conn" set to "null" during Session.close() and thus might happen at several positions during closing the session.

@devgianlu
Copy link
Member

I should probably refactor that part of the code at some point, but for now this should do.

@devgianlu devgianlu merged commit b9afd9c into librespot-org:dev Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants