在下面的代码中,我的期望是如果 list readerList.size = 0
,headerLine
应该null
在 method 内commonValidation()
。但事实并非如此,谁能告诉我为什么?
String[] headerLine = null;
if (readerList != null && readerList.size() != 0){
headerLine = readerList.get(0);
}
commonValidation(headerLine, logDTO, hrGroupName, feedFileName);
//方法定义
public void commonValidation(String[] headerLine, TransactionLogDTO logDTO, String hrGroupName, String filename) throws PersistenceException, ServiceException, Exception {
if ((headerLine == null) || (headerLine.length == 0)){
logDTO.setGyr("R");
String subject = MessageWrapper.getMessage("hr.mail.emptyfile.subject");
String body = MessageWrapper.getMessage("hr.mail.emptyfile.body", filename);
if (logDTO.getMessage() == null){
logDTO.setMessage(body);
}
else{
logDTO.setMessage(logDTO.getMessage() + ";" + body);
}
logDTO.setIsLogErrorMailSent(Boolean.TRUE);
sendTransactionLogErrorReport(hrGroupName, subject, body);
throw new Exception(body);
}
}