DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG· RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=38986>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND· INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=38986 Summary: RequestProcessor does not need synchronization to get action from action map Product: Struts Version: 1.2.8 Platform: All OS/Version: Windows 3.1 Status: NEW Severity: normal Priority: P2 Component: Action AssignedTo: dev@struts.apache.org ReportedBy: [EMAIL PROTECTED] Why dowe have synchronization on get method that returns Action object from the map. It could cause performance issue on high traffic applications. Synchronization only needed around the put method that adds Action object to the map. public class RequestProcessor { . // class level map to cache already created actions protected HashMap actions = new HashMap(); // method to create or get already created action from the map protected Action processActionCreate( ) throws IOException { . Action instance = null; // Synchronize actions map access synchronized (actions) { // get cached action and return it if there is one instance = (Action) actions.get(className); // instance is null at this point, create new instance and put it in the map actions.put(className, instance); } return (instance); } // Comment: Synchronization on getter method is bottleneck that can cause performance issue. Multiple treads(users requests) will be waiting in each other just to get thread safe object from the map. Synchronization only neared in this case if we would need to instantiate Action object to put it in the map. The code above should be re-factored to something as follows: // get cached action and return it if there is one Action instance = (Action) actions.get(className); if(instance==null){ // Synchronize actions map access synchronized (actions) { // instance action from class name and put it in the map actions.put(className, instance); } -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]