[jboss-cvs] JBossAS SVN: r105582 - branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 2 10:27:21 EDT 2010
Author: flavia.rainone at jboss.com
Date: 2010-06-02 10:27:21 -0400 (Wed, 02 Jun 2010)
New Revision: 105582
Added:
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/SecurityActions.java
Modified:
branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/AOPTransformer.java
Log:
[JBAOP-794] Holding the class loader lock before weaving starts should prevent the deadlock from occurring.
Modified: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/AOPTransformer.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/AOPTransformer.java 2010-06-02 12:47:54 UTC (rev 105581)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/AOPTransformer.java 2010-06-02 14:27:21 UTC (rev 105582)
@@ -84,8 +84,12 @@
{
try
{
- //Make sure that we use the correct classloader, in order to get the correct domain if it is a scoped loader
- return AspectManager.instance(loader).transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
+ //Make sure that we use the correct classloader, in order to get the correct domain if it is a scoped loader
+ AspectManager aspectManager = AspectManager.instance(loader);
+ synchronized(SecurityActions.getClassLoader(aspectManager.getClass()))
+ {
+ return aspectManager.transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
+ }
}
catch (Exception e)
{
Added: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/SecurityActions.java
===================================================================
--- branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/SecurityActions.java (rev 0)
+++ branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/SecurityActions.java 2010-06-02 14:27:21 UTC (rev 105582)
@@ -0,0 +1,80 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.aop.standalone;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class SecurityActions
+{
+ interface GetClassLoaderAction
+ {
+ ClassLoader getClassLoader(Class<?> clazz);
+
+ GetClassLoaderAction PRIVILEGED = new GetClassLoaderAction()
+ {
+ public ClassLoader getClassLoader(final Class<?> clazz)
+ {
+ try
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
+ {
+ public ClassLoader run() throws Exception
+ {
+ return clazz.getClassLoader();
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error getting class loader of class " + clazz, e.getException());
+ }
+ }
+ };
+
+ GetClassLoaderAction NON_PRIVILEGED = new GetClassLoaderAction()
+ {
+ public ClassLoader getClassLoader(Class<?> clazz)
+ {
+ return clazz.getClassLoader();
+ }
+ };
+ }
+ static ClassLoader getClassLoader(Class<?> clazz)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ return GetClassLoaderAction.NON_PRIVILEGED.getClassLoader(clazz);
+ }
+ else
+ {
+ return GetClassLoaderAction.PRIVILEGED.getClassLoader(clazz);
+ }
+ }
+
+}
Property changes on: branches/JBoss_AOP_1_5_5_GA_CP/aop/src/jdk15/org/jboss/aop/standalone/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list