File tree Expand file tree Collapse file tree
core/src/main/java/xyz/gianlu/librespot/mercury Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919import java .io .IOException ;
2020import java .nio .ByteBuffer ;
2121import java .util .*;
22- import java .util .concurrent .ConcurrentHashMap ;
2322import java .util .concurrent .atomic .AtomicInteger ;
2423import java .util .concurrent .atomic .AtomicReference ;
2524
@@ -30,7 +29,7 @@ public final class MercuryClient extends PacketsManager {
3029 private static final Logger LOGGER = Logger .getLogger (MercuryClient .class );
3130 private static final int MERCURY_REQUEST_TIMEOUT = 3000 ;
3231 private final AtomicInteger seqHolder = new AtomicInteger (1 );
33- private final Map <Long , Callback > callbacks = new ConcurrentHashMap <>();
32+ private final Map <Long , Callback > callbacks = Collections . synchronizedMap ( new HashMap <>() );
3433 private final List <InternalSubListener > subscriptions = Collections .synchronizedList (new ArrayList <>());
3534 private final Map <Long , BytesArrayList > partials = new HashMap <>();
3635
@@ -247,10 +246,10 @@ public void close() {
247246 }
248247
249248 while (true ) {
250- synchronized (callbacks ) {
251- if ( callbacks . isEmpty ()) {
252- break ;
253- } else {
249+ if (callbacks . isEmpty () ) {
250+ break ;
251+ } else {
252+ synchronized ( callbacks ) {
254253 try {
255254 callbacks .wait (100 );
256255 } catch (InterruptedException ignored ) {
You can’t perform that action at this time.
0 commit comments