Sonar Fixes : DrProvConnection.java
Issue-ID: DMAAP-1100
Change-Id: I1fe275364d281d8fcb3f3b40a6ff2b12777a6c45
Signed-off-by: Sudarshan Kumar <sudars19@in.ibm.com>
return(true);
} catch (Exception e) {
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_ERROR, pURL, e.getMessage() );
return(true);
} catch (Exception e) {
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_ERROR, pURL, e.getMessage() );
logger.info( "artificial 200 response from doPostFeed because unit_test =" + unit_test );
} else {
logger.warn("Unable to read response " );
logger.info( "artificial 200 response from doPostFeed because unit_test =" + unit_test );
} else {
logger.warn("Unable to read response " );
+ errorLogger.error("Unable to read response ", e.getMessage());
try {
err.setCode( uc.getResponseCode());
err.setMessage(uc.getResponseMessage());
try {
err.setCode( uc.getResponseCode());
err.setMessage(uc.getResponseMessage());
finally {
try {
uc.disconnect();
finally {
try {
uc.disconnect();
- } catch ( Exception e ) {}
+ } catch ( Exception e ) {
+ logger.error(e.getMessage(), e);
+ }
logger.info( "artificial 200 response from doXgressPost because unit_test =" + unit_test );
} else {
logger.error("Unable to read response " );
logger.info( "artificial 200 response from doXgressPost because unit_test =" + unit_test );
} else {
logger.error("Unable to read response " );
+ logger.error(e.getMessage(), e);
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
}
rc = uc.getResponseCode();
}
}
rc = uc.getResponseCode();
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doPostDr_Sub because unit_test =" + unit_test );
} else {
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doPostDr_Sub because unit_test =" + unit_test );
} else {
- System.err.println("Unable to read response " );
- e.printStackTrace();
+ logger.error("Unable to read response ", e.getMessage());
}
}
finally {
try {
uc.disconnect();
}
}
finally {
try {
uc.disconnect();
- } catch ( Exception e ) {}
+ } catch ( Exception e ) {
+ logger.error(e.getMessage(), e);
+ }
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
}
rc = uc.getResponseCode();
}
}
rc = uc.getResponseCode();
logger.info( "artificial 200 response from doPutFeed because unit_test =" + unit_test );
} else {
logger.warn("Unable to read response " );
logger.info( "artificial 200 response from doPutFeed because unit_test =" + unit_test );
} else {
logger.warn("Unable to read response " );
+ logger.error(e.getMessage(), e);
}
try {
err.setCode( uc.getResponseCode());
}
try {
err.setCode( uc.getResponseCode());
} catch (Exception e2) {
err.setCode( 500 );
err.setMessage("Unable to determine response message");
} catch (Exception e2) {
err.setCode( 500 );
err.setMessage("Unable to determine response message");
+ logger.error(e2.getMessage(), e2);
}
} finally {
try {
uc.disconnect();
}
} finally {
try {
uc.disconnect();
- } catch ( Exception e ) {}
+ } catch ( Exception e ) {
+ logger.error(e.getMessage(), e);
+ }
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
}
rc = uc.getResponseCode();
}
}
rc = uc.getResponseCode();
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
err.setCode( 500 );
err.setMessage("Backend connection refused");
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
err.setCode( 500 );
err.setMessage("Backend connection refused");
+ logger.error(ce.getMessage(), ce);
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
err.setCode(200);
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
err.setCode(200);
logger.error(e.getMessage(), e);
}
} finally {
logger.error(e.getMessage(), e);
}
} finally {
+ if(null != uc){
+ uc.disconnect();
+ }
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error(e.getMessage(), e);
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
err.setCode( 500 );
err.setMessage("Backend connection refused");
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
err.setCode( 500 );
err.setMessage("Backend connection refused");
+ logger.error(ce.getMessage(), ce);
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
err.setCode(200);
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doGetNodes because unit_test =" + unit_test );
} else {
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
err.setCode(200);
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doGetNodes because unit_test =" + unit_test );
} else {
- System.err.println("Unable to read response " );
- e.printStackTrace();
+ logger.error("Unable to read response ", e.getMessage());
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doPutNodes because unit_test =" + unit_test );
} else {
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doPutNodes because unit_test =" + unit_test );
} else {
- System.err.println("Unable to read response " + e.getMessage() );
- e.printStackTrace();
+ logger.error("Unable to read response ", e.getMessage());
}
} finally {
if ( uc != null ) {
}
} finally {
if ( uc != null ) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
}
rc = uc.getResponseCode();
}
}
rc = uc.getResponseCode();
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
err.setCode( 500 );
err.setMessage("Backend connection refused");
errorLogger.error( DmaapbcLogMessageEnum.HTTP_CONNECTION_EXCEPTION, provURL, ce.getMessage() );
err.setCode( 500 );
err.setMessage("Backend connection refused");
+ logger.error(ce.getMessage(), ce);
} catch (SocketException se) {
errorLogger.error( DmaapbcLogMessageEnum.SOCKET_EXCEPTION, se.getMessage(), "response from Prov server" );
err.setCode( 500 );
err.setMessage( "Unable to read response from DR");
} catch (SocketException se) {
errorLogger.error( DmaapbcLogMessageEnum.SOCKET_EXCEPTION, se.getMessage(), "response from Prov server" );
err.setCode( 500 );
err.setMessage( "Unable to read response from DR");
+ logger.error(se.getMessage(), se);
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
err.setCode(200);
} catch (Exception e) {
if ( unit_test.equals( "Yes" ) ) {
err.setCode(200);
logger.info( "artificial 200 response from doDeleteFeed because unit_test =" + unit_test );
} else {
logger.warn("Unable to read response " );
logger.info( "artificial 200 response from doDeleteFeed because unit_test =" + unit_test );
} else {
logger.warn("Unable to read response " );
+ logger.error(e.getMessage(), e);
try {
err.setCode( uc.getResponseCode());
err.setMessage(uc.getResponseMessage());
} catch (Exception e2) {
err.setCode( 500 );
err.setMessage("Unable to determine response message");
try {
err.setCode( uc.getResponseCode());
err.setMessage(uc.getResponseMessage());
} catch (Exception e2) {
err.setCode( 500 );
err.setMessage("Unable to determine response message");
+ logger.error(e2.getMessage(), e2);
- uc.disconnect();
- } catch ( Exception e ) {}
+ if(uc != null) {
+ uc.disconnect();
+ }
+ } catch ( Exception e ) {
+ logger.error(e.getMessage(), e);
+ }
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error(e.getMessage(), e);
}
}
rc = uc.getResponseCode();
}
}
rc = uc.getResponseCode();
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doDeleteDr_Sub because unit_test =" + unit_test );
} else {
err.setMessage( "simulated response");
logger.info( "artificial 200 response from doDeleteDr_Sub because unit_test =" + unit_test );
} else {
- System.err.println("Unable to read response " );
- e.printStackTrace();
+ logger.error("Unable to read response ", e.getMessage());
+ if(uc != null){
+ uc.disconnect();
+ }