You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2011/12/01 00:54:06 UTC

Re: svn commit: r1208825 - /jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java

On 30 November 2011 22:02,  <pm...@apache.org> wrote:
> Author: pmouawad
> Date: Wed Nov 30 22:02:40 2011
> New Revision: 1208825
>
> URL: http://svn.apache.org/viewvc?rev=1208825&view=rev
> Log:
> Fixed potential double init if method is called concurrently

Not sure that's possible from the GUI, but does no harm.

> Modified:
>    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
>
> Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java?rev=1208825&r1=1208824&r2=1208825&view=diff
> ==============================================================================
> --- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java (original)
> +++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java Wed Nov 30 22:02:40 2011
> @@ -41,6 +41,8 @@ import org.apache.log.Logger;
>  public final class ActionRouter implements ActionListener {
>     private static final Logger log = LoggingManager.getLoggerForClass();
>
> +       private static final Object LOCK = new Object();
> +
>     private static ActionRouter router;
>
>     private Map<String, Set<Command>> commands = new HashMap<String, Set<Command>>();
> @@ -279,8 +281,12 @@ public final class ActionRouter implemen
>      */
>     public static ActionRouter getInstance() {
>         if (router == null) {
> -            router = new ActionRouter();
> -            router.populateCommandMap();
> +               synchronized (LOCK) {
> +                       if(router == null) {
> +                       router = new ActionRouter();
> +                       router.populateCommandMap();
> +                       }
> +                       }
>         }
>         return router;
>     }
>
>