I have an error in the SonarQube of Nullcheck of call when assigning a value to a StorageProcedure.
call.setBigDecimal(ONE, bank != null ? bank : BigDecimal.ZERO);
Exactly in this excerpt above. He makes the same mistake if he removes the ternary. I did an IF before the function and the same error occurred.
enter image description here
public CarrierReturnDTO getMobileCarriers(BigDecimal bank) throws SQLException {
CarrierReturnDTO carrierReturnListDTO = new CarrierReturnDTO();
List<CarrierDTO> mobileCarrierList = new ArrayList<CarrierDTO>();
DataSource dataSource = jdbcTemplate.getDataSource();
if (dataSource != null) {
try (Connection connection = dataSource.getConnection()) {
if (connection != null) {
try (CallableStatement call = connection.prepareCall(Constants.COMBO_OPERCEL)) {
call.setBigDecimal(ONE, bank != null ? bank : BigDecimal.ZERO);
call.registerOutParameter(TWO, OracleTypes.CURSOR);
call.execute();
ResultSet rs = (ResultSet) call.getObject(TWO);
while (rs.next()) {
CarrierDTO mobileCarrier = new CarrierDTO();
mobileCarrier.setMobileCarrierCode(rs.getBigDecimal(Constants.COD_EMP_OPER));
mobileCarrier.setMobileCarrier(rs.getString(Constants.NOM_EMP_OPER));
mobileCarrier.setAmountDigitChecked(rs.getBigDecimal(Constants.QTD_DIG_VERIFIC));
mobileCarrier.setFlagDoubleDigit(rs.getString(Constants.FLG_DUP_DIGIT));
mobileCarrier.setBankCode(rs.getString(Constants.BCO_CNV_ALTAIR));
mobileCarrier.setBranchCode(rs.getString(Constants.AGE_CNV_ALTAIR));
mobileCarrier.setAccountCode(rs.getString(Constants.CTA_CNV_ALTAIR));
mobileCarrierList.add(mobileCarrier);
}
rs.close();
}
}
}
}
carrierReturnListDTO.setCarriers(mobileCarrierList);
return carrierReturnListDTO;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…