@@ -516,7 +516,7 @@ public void close() throws IOException {
516516
517517 private void sendUnchecked (Packet .Type cmd , byte [] payload ) throws IOException {
518518 try {
519- cipherPair .sendEncoded (conn .out , cmd .val , payload );
519+ cipherPair .sendEncoded (conn .out , cmd .val , payload );
520520 } catch (NullPointerException e ) {
521521 throw new IOException (e );
522522 }
@@ -698,7 +698,9 @@ public Configuration configuration() {
698698 }
699699
700700 private void reconnect () {
701- if (!this .closing ) {
701+ if (closing )
702+ return ;
703+
702704 synchronized (reconnectionListeners ) {
703705 reconnectionListeners .forEach (ReconnectionListener ::onConnectionDropped );
704706 }
@@ -722,18 +724,18 @@ private void reconnect() {
722724 synchronized (reconnectionListeners ) {
723725 reconnectionListeners .forEach (ReconnectionListener ::onConnectionEstablished );
724726 }
725- } catch (NullPointerException | IOException | GeneralSecurityException | SpotifyAuthenticationException ex ) {
726- if (! this . closing ) {
727- conn = null ;
728- LOGGER . error ( "Failed reconnecting, retrying in 10 seconds..." , ex );
729-
730- try {
731- scheduler . schedule ( this :: reconnect , 10 , TimeUnit . SECONDS );
732- } catch ( RejectedExecutionException exx ) {
733- LOGGER . info ( "Scheduler already shutdown, stopping reconnection" , exx );
734- }
735- }
736- }
727+ } catch (NullPointerException | IOException | GeneralSecurityException | SpotifyAuthenticationException ex ) {
728+ if (closing )
729+ return ;
730+
731+ conn = null ;
732+ LOGGER . error ( "Failed reconnecting, retrying in 10 seconds..." , ex );
733+
734+ try {
735+ scheduler . schedule ( this :: reconnect , 10 , TimeUnit . SECONDS );
736+ } catch ( RejectedExecutionException exx ) {
737+ LOGGER . info ( "Scheduler already shutdown, stopping reconnection" , exx );
738+ }
737739 }
738740 }
739741
@@ -1320,15 +1322,15 @@ public void run() {
13201322 continue ;
13211323 }
13221324 } catch (IOException | GeneralSecurityException | NullPointerException ex ) {
1323- if (running && ! closing ) {
1325+ if (running ) {
13241326 LOGGER .error ("Failed reading packet!" , ex );
13251327 reconnect ();
13261328 }
13271329
13281330 break ;
13291331 }
13301332
1331- if (!running || closing ) break ;
1333+ if (!running ) break ;
13321334
13331335 switch (cmd ) {
13341336 case Ping :
0 commit comments