33import com .google .gson .JsonObject ;
44import com .spotify .connectstate .Connect ;
55import okhttp3 .HttpUrl ;
6- import org .apache .logging .log4j .LogManager ;
7- import org .apache .logging .log4j .Logger ;
86import org .jetbrains .annotations .NonNls ;
97import org .jetbrains .annotations .NotNull ;
108import org .jetbrains .annotations .Nullable ;
9+ import org .slf4j .Logger ;
10+ import org .slf4j .LoggerFactory ;
1111import xyz .gianlu .librespot .common .NameThreadFactory ;
1212import xyz .gianlu .librespot .common .Utils ;
1313import xyz .gianlu .librespot .core .Session ;
4040public class ZeroconfServer implements Closeable {
4141 private final static int MAX_PORT = 65536 ;
4242 private final static int MIN_PORT = 1024 ;
43- private static final Logger LOGGER = LogManager .getLogger (ZeroconfServer .class );
43+ private static final Logger LOGGER = LoggerFactory .getLogger (ZeroconfServer .class );
4444 private static final byte [] EOL = new byte []{'\r' , '\n' };
4545 private static final JsonObject DEFAULT_GET_INFO_FIELDS = new JsonObject ();
4646 private static final JsonObject DEFAULT_SUCCESSFUL_ADD_USER = new JsonObject ();
@@ -247,19 +247,19 @@ private void handleGetInfo(OutputStream out, String httpVersion) throws IOExcept
247247 private void handleAddUser (OutputStream out , Map <String , String > params , String httpVersion ) throws GeneralSecurityException , IOException {
248248 String username = params .get ("userName" );
249249 if (username == null || username .isEmpty ()) {
250- LOGGER .fatal ("Missing userName!" );
250+ LOGGER .error ("Missing userName!" );
251251 return ;
252252 }
253253
254254 String blobStr = params .get ("blob" );
255255 if (blobStr == null || blobStr .isEmpty ()) {
256- LOGGER .fatal ("Missing blob!" );
256+ LOGGER .error ("Missing blob!" );
257257 return ;
258258 }
259259
260260 String clientKeyStr = params .get ("clientKey" );
261261 if (clientKeyStr == null || clientKeyStr .isEmpty ()) {
262- LOGGER .fatal ("Missing clientKey!" );
262+ LOGGER .error ("Missing clientKey!" );
263263 return ;
264264 }
265265
@@ -300,7 +300,7 @@ private void handleAddUser(OutputStream out, Map<String, String> params, String
300300 byte [] mac = hmac .doFinal ();
301301
302302 if (!Arrays .equals (mac , checksum )) {
303- LOGGER .fatal ("Mac and checksum don't match!" );
303+ LOGGER .error ("Mac and checksum don't match!" );
304304
305305 out .write (httpVersion .getBytes ());
306306 out .write (" 400 Bad Request" .getBytes ()); // I don't think this is the Spotify way
@@ -355,7 +355,7 @@ private void handleAddUser(OutputStream out, Map<String, String> params, String
355355
356356 sessionListeners .forEach (l -> l .sessionChanged (session ));
357357 } catch (Session .SpotifyAuthenticationException | MercuryClient .MercuryException | IOException | GeneralSecurityException ex ) {
358- LOGGER .fatal ("Couldn't establish a new session." , ex );
358+ LOGGER .error ("Couldn't establish a new session." , ex );
359359
360360 synchronized (connectionLock ) {
361361 connectingUsername = null ;
@@ -465,11 +465,11 @@ public void run() {
465465 handle (socket );
466466 socket .close ();
467467 } catch (IOException ex ) {
468- LOGGER .fatal ("Failed handling request!" , ex );
468+ LOGGER .error ("Failed handling request!" , ex );
469469 }
470470 });
471471 } catch (IOException ex ) {
472- if (!shouldStop ) LOGGER .fatal ("Failed handling connection!" , ex );
472+ if (!shouldStop ) LOGGER .error ("Failed handling connection!" , ex );
473473 }
474474 }
475475 }
@@ -481,13 +481,13 @@ private void handleRequest(@NotNull OutputStream out, @NotNull String httpVersio
481481 try {
482482 handleAddUser (out , params , httpVersion );
483483 } catch (GeneralSecurityException | IOException ex ) {
484- LOGGER .fatal ("Failed handling addUser!" , ex );
484+ LOGGER .error ("Failed handling addUser!" , ex );
485485 }
486486 } else if (Objects .equals (action , "getInfo" )) {
487487 try {
488488 handleGetInfo (out , httpVersion );
489489 } catch (IOException ex ) {
490- LOGGER .fatal ("Failed handling getInfo!" , ex );
490+ LOGGER .error ("Failed handling getInfo!" , ex );
491491 }
492492 } else {
493493 LOGGER .warn ("Unknown action: " + action );
@@ -522,13 +522,13 @@ private void handle(@NotNull Socket socket) throws IOException {
522522 if (Objects .equals (method , "POST" )) {
523523 String contentType = headers .get ("Content-Type" );
524524 if (!Objects .equals (contentType , "application/x-www-form-urlencoded" )) {
525- LOGGER .fatal ("Bad Content-Type: " + contentType );
525+ LOGGER .error ("Bad Content-Type: " + contentType );
526526 return ;
527527 }
528528
529529 String contentLengthStr = headers .get ("Content-Length" );
530530 if (contentLengthStr == null ) {
531- LOGGER .fatal ("Missing Content-Length header!" );
531+ LOGGER .error ("Missing Content-Length header!" );
532532 return ;
533533 }
534534
0 commit comments