Explorar o código

Fixed getting Auth cookie concurrently

Lukas Cerny %!s(int64=4) %!d(string=hai) anos
pai
achega
863be2d916

+ 3 - 3
src/main/java/cz/senslog/watchdog/core/connection/SensLogWSConnection.java

@@ -30,7 +30,7 @@ public class SensLogWSConnection {
         this.authCookie = Tuple.of(false, null);
     }
 
-    private HttpCookie getAuthCookie() {
+    private synchronized HttpCookie getAuthCookie() {
         if (authCookie.getItem1()) {
             return authCookie.getItem2();
         }
@@ -41,10 +41,10 @@ public class SensLogWSConnection {
                         .addParam("password", config.getAuth().getPassword())
                         .build()
                 ).build();
-        logger.info("Getting new data from the server: {}.", request.getUrl());
+        logger.info("Getting new auth cookie from the server: {}.", config.getBaseUrl());
 
         HttpResponse response = httpClient.send(request);
-        logger.info("Received data with the status '{}' from the server {}.", response.getStatus(), request.getUrl());
+        logger.info("Received data with the status '{}' from the server {}.", response.getStatus(), config.getBaseUrl());
 
         if (response.isError()) {
             logger.warn("Authorization failed. Error code {} with the reason '{}'.", response.getStatus(), response.getBody());