File tree Expand file tree Collapse file tree
lib/src/main/java/xyz/gianlu/librespot/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323import okhttp3 .OkHttpClient ;
2424import okhttp3 .Request ;
2525import okhttp3 .Response ;
26+ import okhttp3 .ResponseBody ;
2627import org .jetbrains .annotations .NotNull ;
2728import org .slf4j .Logger ;
2829import org .slf4j .LoggerFactory ;
@@ -81,9 +82,10 @@ private void request(@NotNull String... types) throws IOException {
8182 Request request = new Request .Builder ()
8283 .url (url .toString ())
8384 .build ();
84- Response response = client .newCall (request ).execute ();
85- if (response .isSuccessful ()) {
86- try (Reader reader = response .body ().charStream ()) {
85+ try (Response response = client .newCall (request ).execute ()) {
86+ ResponseBody body = response .body ();
87+ if (body == null ) throw new IOException ("No body" );
88+ try (Reader reader = body .charStream ()) {
8789 JsonObject obj = JsonParser .parseReader (reader ).getAsJsonObject ();
8890 HashMap <String , List <String >> map = new HashMap <>();
8991 for (String type : types )
You can’t perform that action at this time.
0 commit comments