ER-203 Do not use instance or class non-final variables in Struts Action.

Severity1
Enabledno
Waivable
RationaleIn 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();
		}

	}	 


Hammurapi 3 Copyright © 2004 Hammurapi Group. All Rights Reserved.