Severity | 1 |
---|---|
Enabled | no |
Waivable | |
Rationale | In multithreading environment value of instance/class variable can be changed from one thread and the be read by another which will lead to data corruption. |
Violation |
public class EmployeeAction extends DispatchAction { //-- violation private String path = ""; //-- OK private static Logger logger = Logger.getLogger(EmployeeAction.class.getName()); } |
Fix |
public class EmployeeAction extends DispatchAction { //-- OK private static Logger logger = Logger.getLogger(EmployeeAction.class.getName()); public void execute(){ //-- move instance variable to local variable String path = ""; BusinessDelegate b = new BusinessDelegate(); b.insertEmployee(); } } |