我正在为Jenkins玩Sonarqube插件。如何在不改变逻辑的情况下有效地解决他所抱怨的这种微不足道的违规行为?
注意:我需要separetely验证连接(ConnectionManager,statistics,keepAlive,..)。
`
public void executeProcedure( final RequestProcessor consumer ) throws SQLException {
final String procedure = consumer.getProcedure();
final String idUrl = consumer.getIdUrl();
final PreparedStatementRegisterer stmRegisterer = consumer.getRegisterer();
// Autoclosable removed to allow ad hoc connection validation
Connection conn = null;
boolean execSuccess = false;
try{
conn = newConnection();
conn = checkOrChangeConnection(conn, false);
boolean hasResultSet = false;
try( CallableStatement statement = (OracleCallableStatement)conn.prepareCall(procedure) ){
...
stmRegisterer.prepareStatement(statement, idUrl);
statement.setQueryTimeout(QUERY_TIMEOUT);
hasResultSet = statement.execute();
execSuccess = true;
if(hasResultSet){
...
try ( ResultSet rs = statement.getResultSet() ) {
while ( rs.next() ) {
consumer.handleRow( rs );
}
}
}else{
...
consumer.getFieldsFromResult( statement );
}
}
}catch(Exception ex){
LOGGER.log( LogEntries.StorProcErr, ex.getMessage() );
throw new Exception( (!execSuccess ? "Error preparing and executing statement.":"Error during results reading.")+" Cause: "+ex) );
}finally{
try {
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
System.out.println("\n Error closing connection on executeStoredProc. Cause: "+e+" \n"); // log
}
}
}
我的想法是在log" StorProcErr"之后添加更多日志并重新抛出相同的异常。有更好的方法吗?
由于