戈壁堂

Knowledge Is Action

Sonar扫描的NPE问题

直到我修改为这样的代码才通过——


public class DetectorImport {
    public String check1(Nonentity nonentity) {
        String s;
        if(nonentity == null) {
            s = null;
        }else {
            s = nonentity.getName();
        }
        if(s !=null) {
            s = s.replaceAll("(", "(");
        }
        return s;
    }
}