Skip to content

Commit 9c2fb72

Browse files
committed
Minor clean up (Codacy again)
1 parent 2e35d9b commit 9c2fb72

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

api/src/main/java/xyz/gianlu/librespot/api/handlers/MetadataHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
5959
try {
6060
JsonObject obj = handle(type, uri);
6161
exchange.getResponseSender().send(obj.toString());
62-
} catch (IOException | MercuryClient.MercuryException ex) {
63-
if (ex instanceof ApiClient.StatusCodeException) {
64-
if (((ApiClient.StatusCodeException) ex).code == 404) {
65-
Utils.invalidParameter(exchange, "uri", "404: Unknown uri");
66-
return;
67-
}
62+
} catch (ApiClient.StatusCodeException ex) {
63+
if (ex.code == 404) {
64+
Utils.invalidParameter(exchange, "uri", "404: Unknown uri");
65+
return;
6866
}
6967

68+
Utils.internalError(exchange, ex);
69+
LOGGER.error(String.format("Failed handling api request. {type: %s, uri: %s, code: %d}", type, uri, ex.code), ex);
70+
} catch (IOException | MercuryClient.MercuryException ex) {
7071
Utils.internalError(exchange, ex);
7172
LOGGER.error(String.format("Failed handling api request. {type: %s, uri: %s}", type, uri), ex);
7273
} catch (IllegalArgumentException ex) {

common/src/main/java/xyz/gianlu/librespot/common/ProtobufToJson.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ private static void put(JsonObject json, Descriptors.FieldDescriptor descriptor,
102102
else if (descriptor.isRepeated()) json.add(key, array((List<? extends Message>) obj));
103103
else json.add(key, convert((Message) obj));
104104
break;
105+
default:
106+
throw new IllegalStateException("Unknown type: " + descriptor.getJavaType());
105107
}
106108
}
107109
}

core/src/main/java/xyz/gianlu/librespot/mercury/model/PlayableId.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import xyz.gianlu.librespot.common.Utils;
88

99
import java.util.List;
10+
import java.util.Objects;
1011

1112
/**
1213
* @author Gianlu
@@ -39,7 +40,8 @@ static PlayableId from(@NotNull Player.ProvidedTrack track) {
3940
}
4041

4142
static boolean isSupported(@NotNull String uri) {
42-
return !uri.startsWith("spotify:local:") && !uri.equals("spotify:delimiter") && !uri.equals("spotify:meta:delimiter");
43+
return !uri.startsWith("spotify:local:") && !Objects.equals(uri, "spotify:delimiter")
44+
&& !Objects.equals(uri, "spotify:meta:delimiter");
4345
}
4446

4547
static boolean shouldPlay(@NotNull ContextTrack track) {

0 commit comments

Comments
 (0)