summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArundathi Patil <arundpil@in.ibm.com>2018-09-03 13:54:42 +0530
committerIBM602-PC0F1E3C\Arundathi <arundpil@in.ibm.com>2018-09-03 13:56:19 +0530
commit9ef23e94ec231d9051090420d7e8db7ba95bfe4d (patch)
tree405926f73b73c18a6bcd187aa8453b84a21cb904
parent8b80c9a3005862032908478570f9c500bf0d9fb5 (diff)
MrTopicConnection.java: Fixed sonar issue
Fixed sonar code-smells/issues accross this file Issue-ID: DMAAP-703 Change-Id: Ibf844f824a2d21edb0055702a685bff98c52f768 Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
index 18fdeba..492037c 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
@@ -33,7 +33,6 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException;
import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.MR_Cluster;
@@ -81,7 +80,7 @@ public class MrTopicConnection extends BaseLoggingClass {
return(true);
} catch (Exception e) {
logger.error("Unexpected error during openConnection of " + pURL );
- e.printStackTrace();
+ logger.error("Error", e);;
return(false);
}
@@ -97,7 +96,7 @@ public class MrTopicConnection extends BaseLoggingClass {
return(true);
} catch (Exception e) {
logger.error("Unexpected error during openConnection of " + pURL );
- e.printStackTrace();
+ logger.error("error", e);
return(false);
}
@@ -147,13 +146,10 @@ public class MrTopicConnection extends BaseLoggingClass {
} catch (ProtocolException pe) {
// Rcvd error instead of 100-Continue
- try {
- // work around glitch in Java 1.7.0.21 and likely others
- // without this, Java will connect multiple times to the server to run the same request
- uc.setDoOutput(false);
- } catch (Exception e) {
- }
+ callSetDoOutputOnError();
+
} catch ( SSLException se ) {
+ logger.error("Error", se);
response.setCode(500);
response.setMessage( se.getMessage());
return response;
@@ -194,16 +190,28 @@ public class MrTopicConnection extends BaseLoggingClass {
response.setCode(500);
response.setMessage( "Unable to read response");
logger.warn( response.getMessage() );
- e.printStackTrace();
+ logger.error("Error", e);
}
}
finally {
try {
uc.disconnect();
- } catch ( Exception e ) {}
+ } catch ( Exception e ) {
+ logger.error("Error", e);
+ }
}
return response;
}
+
+ public void callSetDoOutputOnError() {
+ try {
+ // work around glitch in Java 1.7.0.21 and likely others
+ // without this, Java will connect multiple times to the server to run the same request
+ uc.setDoOutput(false);
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }
+ }
}