summaryrefslogtreecommitdiffstats
path: root/cloudify-client/src
diff options
context:
space:
mode:
authorParshad Patel <pars.patel@samsung.com>2019-09-02 15:02:28 +0900
committerParshad Patel <pars.patel@samsung.com>2019-09-02 19:05:34 +0900
commit7995ef475cc8b064b94d9ba54df4dbd8e15645d0 (patch)
treef4c6303d2c787145864414c90ff60128b1740e2d /cloudify-client/src
parent687cdacb9fd74629e94ebc0914ba8c72bb5015a5 (diff)
Fix issues in so-cloudify-client
Annotate the "CloudifyClientConnector" interface with the @FunctionalInterface annotation Make this field final Either log or rethrow this exception Make "response" transient or serializable Issue-ID: SO-1841 Change-Id: I13fa6b911d8789aed26fd27da23318f6dbca3760 Signed-off-by: Parshad Patel <pars.patel@samsung.com>
Diffstat (limited to 'cloudify-client/src')
-rw-r--r--cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java6
-rw-r--r--cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java10
-rw-r--r--cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java11
-rw-r--r--cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java6
4 files changed, 18 insertions, 15 deletions
diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java
index f031f10bb5..652df6ff0d 100644
--- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java
+++ b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyClientConnector.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@
package org.onap.so.cloudify.base.client;
-
+@FunctionalInterface
public interface CloudifyClientConnector {
public <T> CloudifyResponse request(CloudifyRequest<T> request);
diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java
index 966cc8f144..0ca3212238 100644
--- a/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java
+++ b/cloudify-client/src/main/java/org/onap/so/cloudify/base/client/CloudifyResponseException.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,11 +26,11 @@ public class CloudifyResponseException extends CloudifyBaseException {
private static final long serialVersionUID = 7294957362769575271L;
- protected String message;
- protected int status;
+ private final String message;
+ private final int status;
// Make the response available for exception handling (includes body)
- protected CloudifyResponse response;
+ private final CloudifyResponse response;
public CloudifyResponseException(String message, int status) {
this.message = message;
diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java
index ba6a5911b7..54519bac72 100644
--- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java
+++ b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientConnector.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -94,7 +94,7 @@ public class HttpClientConnector implements CloudifyClientConnector {
public <T> CloudifyResponse request(CloudifyRequest<T> request) {
- CloseableHttpClient httpClient = null; // HttpClients.createDefault();
+ CloseableHttpClient httpClient = null;
if (request.isBasicAuth()) {
// Use Basic Auth for this request.
@@ -211,11 +211,14 @@ public class HttpClientConnector implements CloudifyClientConnector {
} catch (HttpResponseException e) {
// What exactly does this mean? It does not appear to get thrown for
// non-2XX responses as documented.
+ logger.error("Client HttpResponseException", e);
throw new CloudifyResponseException(e.getMessage(), e.getStatusCode());
} catch (UnknownHostException e) {
+ logger.error("Client UnknownHostException", e);
throw new CloudifyConnectException("Unknown Host: " + e.getMessage());
} catch (IOException e) {
// Catch all other IOExceptions and throw as OpenStackConnectException
+ logger.error("Client IOException", e);
throw new CloudifyConnectException(e.getMessage());
} catch (Exception e) {
// Catchall for anything else, must throw as a RuntimeException
@@ -227,7 +230,7 @@ public class HttpClientConnector implements CloudifyClientConnector {
try {
httpResponse.close();
} catch (IOException e) {
- logger.debug("Unable to close HTTP Response: " + e);
+ logger.debug("Unable to close HTTP Response: ", e);
}
}
diff --git a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java
index a96fdb6b50..f1aa06cb39 100644
--- a/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java
+++ b/cloudify-client/src/main/java/org/onap/so/cloudify/connector/http/HttpClientResponse.java
@@ -9,9 +9,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@ public class HttpClientResponse implements CloudifyResponse {
private static Logger logger = LoggerFactory.getLogger(HttpClientResponse.class);
- private HttpResponse response = null;
+ private transient HttpResponse response = null;
private String entityBody = null;
public HttpClientResponse(HttpResponse response) {