craigmcc 02/03/15 18:07:11 Modified: src/share/org/apache/struts/action RequestProcessor.java Log: Avoid the use of the "double checked locking" idiom when locating an Action instance to use (or creating one if necessary). Since we're going synchronize on the "actions" collection anyway, there is no benefit in using a FastHashMap, so go back to a standard HashMap as well. PR: Bugzilla #7060 Submitted by: Michael Rimov <rimovm at centercorp.com> Revision Changes Path 1.8 +23 -21 jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java Index: RequestProcessor.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- RequestProcessor.java 10 Mar 2002 01:23:29 -0000 1.7 +++ RequestProcessor.java 16 Mar 2002 02:07:11 -0000 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v 1.7 2002/03/10 01:23:29 craigmcc Exp $ - * $Revision: 1.7 $ - * $Date: 2002/03/10 01:23:29 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/RequestProcessor.java,v 1.8 2002/03/16 02:07:11 craigmcc Exp $ + * $Revision: 1.8 $ + * $Date: 2002/03/16 02:07:11 $ * * ==================================================================== * @@ -64,6 +64,7 @@ import java.io.IOException; +import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import javax.servlet.RequestDispatcher; @@ -72,7 +73,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.collections.FastHashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.config.ActionConfig; @@ -94,7 +94,7 @@ * interested in changing.</p> * * @author Craig R. McClanahan - * @version $Revision: 1.7 $ $Date: 2002/03/10 01:23:29 $ + * @version $Revision: 1.8 $ $Date: 2002/03/16 02:07:11 $ * @since Struts 1.1 */ @@ -127,7 +127,7 @@ * The set of Action instances that have been created and initialized, * keyed by the fully qualified Java class name of the Action class. */ - protected FastHashMap actions = new FastHashMap(); + protected HashMap actions = new HashMap(); /** @@ -181,9 +181,7 @@ throws ServletException { synchronized (actions) { - actions.setFast(false); actions.clear(); - actions.setFast(true); } this.servlet = servlet; this.appConfig = appConfig; @@ -296,21 +294,22 @@ if (log.isDebugEnabled()) { log.debug(" Looking for Action instance for class " + className); } - Action instance = (Action) actions.get(className); - if (instance != null) { - if (log.isTraceEnabled()) { - log.trace(" Returning existing Action instance of class '" + - className + "'"); + Action instance = null; + synchronized (actions) { + + // Return any existing Action instance of this class + instance = (Action) actions.get(className); + if (instance != null) { + if (log.isTraceEnabled()) { + log.trace(" Returning existing Action instance"); + } + return (instance); } - return (instance); - } - // Create a new Action instance if necessary - if (log.isTraceEnabled()) { - log.trace(" Creating new Action instance of class '" + - className + "'"); - } - synchronized (actions) { + // Create and return a new Action instance + if (log.isTraceEnabled()) { + log.trace(" Creating new Action instance"); + } try { instance = (Action) RequestUtils.applicationInstance(className); @@ -325,8 +324,11 @@ mapping.getPath())); return (null); } + } + return (instance); + }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>