On 20/05/2010 16:25, jfcl...@apache.org wrote:
> Author: jfclere
> Date: Thu May 20 15:25:13 2010
> New Revision: 946671
> 
> URL: http://svn.apache.org/viewvc?rev=946671&view=rev
> Log:
> Prevent core due to wrong synchronisation.
> 
> Modified:
>     tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java
> 
> Modified: tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java?rev=946671&r1=946670&r2=946671&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java 
> (original)
> +++ tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java Thu 
> May 20 15:25:13 2010
> @@ -72,9 +72,15 @@ public class AprLifecycleListener
>      protected static boolean sslAvailable = false;
>      protected static boolean aprAvailable = false;
>  
> +    protected static String lock = "";
> +

Better as:

protected static Object lock = new Object();

Mark

>      public static boolean isAprAvailable() {
>          //https://issues.apache.org/bugzilla/show_bug.cgi?id=48613
> -        if (instanceCreated) init();
> +        if (instanceCreated) {
> +            synchronized (lock) {
> +                init();
> +            }
> +        }
>          return aprAvailable;
>      }
>      
> @@ -92,28 +98,32 @@ public class AprLifecycleListener
>      public void lifecycleEvent(LifecycleEvent event) {
>  
>          if (Lifecycle.INIT_EVENT.equals(event.getType())) {
> -            init();
> -            if (aprAvailable) {
> -                try {
> -                    initializeSSL();
> -                } catch (Throwable t) {
> -                    log.info(sm.getString("aprListener.sslInit"));
> +            synchronized (lock) {
> +                init();
> +                if (aprAvailable) {
> +                    try {
> +                        initializeSSL();
> +                    } catch (Throwable t) {
> +                        log.info(sm.getString("aprListener.sslInit"));
> +                    }
>                  }
>              }
>          } else if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType())) {
> -            if (!aprAvailable) {
> -                return;
> -            }
> -            try {
> -                terminateAPR();
> -            } catch (Throwable t) {
> -                log.info(sm.getString("aprListener.aprDestroy"));
> +            synchronized (lock) {
> +                if (!aprAvailable) {
> +                    return;
> +                }
> +                try {
> +                    terminateAPR();
> +                } catch (Throwable t) {
> +                    log.info(sm.getString("aprListener.aprDestroy"));
> +                }
>              }
>          }
>  
>      }
>  
> -    private static synchronized void terminateAPR()
> +    private static void terminateAPR()
>          throws ClassNotFoundException, NoSuchMethodException,
>                 IllegalAccessException, InvocationTargetException
>      {
> @@ -121,6 +131,8 @@ public class AprLifecycleListener
>          Method method = Class.forName("org.apache.tomcat.jni.Library")
>              .getMethod(methodName, (Class [])null);
>          method.invoke(null, (Object []) null);
> +        aprAvailable = false;
> +        aprInitialized = false;
>      }
>  
>      private static void init()
> @@ -188,7 +200,7 @@ public class AprLifecycleListener
>          aprAvailable = true;
>      }
>  
> -    private static synchronized void initializeSSL()
> +    private static void initializeSSL()
>          throws ClassNotFoundException, NoSuchMethodException,
>                 IllegalAccessException, InvocationTargetException
>      {
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to