private void waitForChannelResubscription ( final Map < Integer , ChannelCallbackHandler > oldChannelIdSymbolMap ) throws BitfinexClientException , InterruptedException { final Stopwatch stopwatch = Stopwatch . createStarted ( ) ; final long MAX_WAIT_TIME_IN_MS = TimeUnit . MINUTES . toMillis ( 3 ) ; logger . info ( "Waiting for streams to resubscribe (max wait time {} msec)" , MAX_WAIT_TIME_IN_MS ) ; synchronized ( channelIdToHandlerMap ) { while ( channelIdToHandlerMap . size ( ) != oldChannelIdSymbolMap . size ( ) ) { if ( stopwatch . elapsed ( TimeUnit . MILLISECONDS ) > MAX_WAIT_TIME_IN_MS ) { // Raise BitfinexClientException handleResubscribeFailed ( oldChannelIdSymbolMap ) ; } channelIdToHandlerMap . wait ( 500 ) ; } } }
Wait for the successful channel re - subscription