Fix bugs in Rest Client 07/55707/2
authorWiktor Garbarek <wiktor.garbarek@nokia.com>
Tue, 3 Jul 2018 13:53:48 +0000 (15:53 +0200)
committerWiktor Garbarek <wiktor.garbarek@nokia.com>
Tue, 3 Jul 2018 13:57:53 +0000 (15:57 +0200)
Fixed handling InterruptedException and NullPointerException

Change-Id: I4a7f0d73394bc8c7cbdce5bc424104edcc036fe4
Issue-ID: AAI-1359
Signed-off-by: Wiktor Garbarek <wiktor.garbarek@nokia.com>
pom.xml
src/main/java/org/onap/aai/restclient/client/RestClient.java

diff --git a/pom.xml b/pom.xml
index b469d68..3ed13c3 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -90,9 +90,14 @@ limitations under the License.
                        <artifactId>powermock-module-junit4-rule-agent</artifactId>
                        <version>1.6.2</version>
                        <scope>test</scope>
-               </dependency>           
+               </dependency>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>javax.ws.rs-api</artifactId>
+      <version>2.0</version>
+    </dependency>
 
-       </dependencies>
+  </dependencies>
 
        <build>
                <pluginManagement>
index a00c0ef..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) {