Skip to content

Commit dfd6bc9

Browse files
committed
Shutdown OkHttp on closing (fixed #235)
1 parent c34d20e commit dfd6bc9

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/core/Session.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,9 @@ public void close() throws IOException {
472472

473473
executorService.shutdown();
474474

475+
client.dispatcher().executorService().shutdownNow();
476+
client.connectionPool().evictAll();
477+
475478
if (conn != null) {
476479
conn.socket.close();
477480
conn = null;

core/src/main/java/xyz/gianlu/librespot/dealer/DealerClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ public void onMessage(@NotNull WebSocket ws, @NotNull String text) {
366366

367367
@Override
368368
public void onFailure(@NotNull WebSocket ws, @NotNull Throwable t, @Nullable Response response) {
369+
if (closed) return;
370+
369371
LOGGER.warn("An exception occurred. Reconnecting...", t);
370372
ConnectionHolder.this.close();
371373
}

0 commit comments

Comments
 (0)