Fix bugs in Rest Client
[aai/rest-client.git] / src / main / java / org / onap / aai / restclient / client / RestClient.java
index cfeeb27..f4f184c 100644 (file)
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentMap;
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.Response;
 
 import org.onap.aai.restclient.enums.RestAuthenticationMode;
@@ -319,6 +320,7 @@ public class RestClient {
 
       } catch (InterruptedException e) {
         logger.error(RestClientMsgs.HTTP_REQUEST_INTERRUPTED, url, e.getLocalizedMessage());
+        Thread.currentThread().interrupt();
         break;
       }
     }
@@ -381,7 +383,9 @@ public class RestClient {
       populateOperationResult(clientResponse, operationResult);
 
       // Debug log the response
-      debugResponse(operationResult, clientResponse.getHeaders());
+      if (clientResponse != null) {
+        debugResponse(operationResult, clientResponse.getHeaders());
+      }
 
     } catch (Exception ex) {
 
@@ -611,7 +615,9 @@ public class RestClient {
         builder.header(header.getKey(), String.join(";",header.getValue()));
       }
       
-      if (clientBuilder.getAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) {
+      //Added additional check to prevent adding duplicate authorization header if client is already sending the authorization header 
+      // AAI-1097 - For AAI calls when Rest authentication mode is selected as SSL_BASIC getting 403 error
+      if (clientBuilder.getAuthenticationMode() == RestAuthenticationMode.SSL_BASIC && headers.get(Headers.AUTHORIZATION) == null) {
         builder = builder.header(Headers.AUTHORIZATION,
             clientBuilder.getBasicAuthenticationCredentials());
       }