[jboss-user] [JBoss AOP] - Method Advised class on getInterceptorChainReadWriteLock wit

pcross616 do-not-reply at jboss.com
Thu Feb 26 04:27:00 EST 2009


I been searching the JIRA bugs related to AOP but not finding anything so I thought I might see if anyone has any suggestions.

We have upgraded from AOP 1.5.6 in JBoss 4.2.2 GA to JBoss 5.0.1 using AOP 2.0.0 GA and are using the new instrumentor.  All of the code was working in the older version of AOP.

Here is the issue we are having now in JBoss 5.0.1.  We have a set of objects that are access from different threads located in a thread safe map.  These objects have Pointcuts defined on these objects for both fields and methods.  During execution we get in a state when a read is occuring on the object with the MethodInfo interceptor chain locked by a ReadLock and another Object in the map write lock during a GeneratedClassAdvisor checkVersion call.  It seems like somewhere in the advised classes the system is getting in to a state where the unlock never happens.  Whenever another thread that attempts to use the object and or maybe even the advised class in question it will get BLOCKED.  The methods have a single PER_VM instance aspect and the fields have a PER_INSTANCE aspect attached to each object in the Map.  We are using mixins with the object in the map.


jboss-aop.xml -- example aop configuration.

  | <aop xmlns="urn:jboss:aop-beans:1.0">
  |     <aspect class="com.company.common.item.aspect.MethodAspect"/>
  |     <aspect class="com.company.common.item.aspect.FieldAspect" scope="PER_INSTANCE"/>
  | 
  |     <bind pointcut="execution(* *->@com.company.common.item.aspect.ObjectMethod(..)) OR
  |                     execution(* @com.company.common.item.aspect.ObjectMethod->*(..)) OR
  |                     execution(* @com.company.common.item.aspect.ObjectItem->*(..))">
  | 
  |         <advice name="trace"
  |                 aspect="com.company.common.item.aspect.MethodAspect"/>
  |     </bind>
  |     
  |     <bind pointcut="field(* @com.company.common.item.aspect.ObjectItem->*)">
  |         <advice name="check"
  |             aspect="com.company.common.cache.aspect.FieldAspect"/>
  |     </bind>
  | 
  |     <introduction class="@com.company.common.item.aspect.ObjectItem">
  |         <mixin>
  |             <interfaces>com.company.common.item.aspect.ILoadable</interfaces>
  |             <class>com.company.common.item.aspect.ObjectLoader</class>
  |             <construction>new com.company.common.item.aspect.ObjectLoader(this)</construction>
  |         </mixin>
  |     </introduction>
  | </aop>
  | 


JStack output during a locked situations.  All locks were waiting no running threads were active in our code it was all locked in the Advisors.

Read Lock -- case

  | condition [0x000000004aa6a000..0x000000004aa6eb00]
  |    java.lang.Thread.State: WAITING (parking)
  |         at sun.misc.Unsafe.park(Native Method)
  |         - parking to wait for  <0x00007f30d52a4868> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
  |         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
  |         at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
  |         at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireShared(AbstractQueuedSynchronizer.java:877)
  |         at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireShared(AbstractQueuedSynchronizer.java:1197)
  |         at java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock.lock(ReentrantReadWriteLock.java:594)
  |         at com.company.common.item.common.UserInfo$UserInfoAdvisor.setEmail_N_4117224176847888539(UserInfo$UserInfoAdvisor.java)
  |         at com.company.common.item.common.UserInfo$UserInfoInstanceAdvisor.setEmail_N_4117224176847888539(UserInfo$UserInfoInstanceAdvisor.java)
  |         at com.company.common.item.common.UserInfo.setEmail(UserInfo.java)
  | 


Write Lock -- case

  | condition [0x000000004ac6e000..0x000000004ac70a00]
  |    java.lang.Thread.State: WAITING (parking)
  |         at sun.misc.Unsafe.park(Native Method)
  |         - parking to wait for  <0x00007f30d51a5858> (a java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
  |         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
  |         at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:747)
  |         at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:778)
  |         at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1114)
  |         at java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:807)
  |         at com.company.common.item.common.UserInfo$UserInfoInstanceAdvisor.lockWriteInterceptorChains(UserInfo$UserInfoInstanceAdvisor.java)
  |         at com.company.common.item.common.UserInfo$UserInfoInstanceAdvisor.doRebuildForInstance(UserInfo$UserInfoInstanceAdvisor.java)
  |         at org.jboss.aop.GeneratedClassAdvisor$InstanceAdvisorStrategy.checkVersion(GeneratedClassAdvisor.java:1616)
  |         at org.jboss.aop.GeneratedClassAdvisor.checkVersion(GeneratedClassAdvisor.java:268)
  |         at com.company.common.item.common.UserInfo$UserInfoInstanceAdvisor.getUID_N_622210694221713302(UserInfo$UserInfoInstanceAdvisor.java)
  |         at com.company.common.item.common.UserInfo.getUID(UserInfo.java)
  | 


I decompiled the advised class to see the structure of the implementation for the Pointcuts and it seems to have all the appropriate unlock statements in finally blocks and all exception cases from the best i can tell.
I dont understand why it is trying to doRebuildForInstance().



  | //DECOMPILED Advised Class
  | 
  | public class UserInfo
  |     implements IUserInfo, Advised, ILoadable
  | {
  |     public static class UserInfoAdvisor extends GeneratedClassAdvisor
  |         implements Untransformable
  |     {
  | 
  |         public Domain getDomain()
  |         {
  |             return domain;
  |         }
  | 
  |         protected void initialiseMethods()
  |         {
  |             Object obj = null;
  |             aop$MethodInfo_getEmail99631339274670319 = new MethodInfo(Class.forName("com.company.common.item.common.UserInfo"), 0x161f62cd9f690efL, 0xefeef414804be60eL, this);
  |             addMethodInfo(aop$MethodInfo_getEmail99631339274670319);
  |             Object obj1 = null;
  |             aop$MethodInfo_getStartPage_N_8828064419336332239 = new MethodInfo(Class.forName("com.company.common.item.common.UserInfo"), 0x857c6a2f07315c31L, 0xf71910379dc11de3L, this);
  |             addMethodInfo(aop$MethodInfo_getStartPage_N_8828064419336332239);
  |             Object obj2 = null;
  |             aop$MethodInfo_getHome4315750976580329194 = new MethodInfo(Class.forName("com.company.common.item.common.UserInfo"), 0x3be4a0a5ba1d9eeaL, 0xb7a3ea639c9f4219L, this);
  |             addMethodInfo(aop$MethodInfo_getHome4315750976580329194);
  | 		
  | 	    .... truncated ....
  | 	}
  | 
  |         protected void initialiseConstructors(Collection collection)
  |         {
  |         }
  | 
  |         protected void initialiseConstructions(Collection collection)
  |         {
  |         }
  | 
  |         protected void initialiseFieldReads(Collection collection)
  |         {
  |             Object obj = null;
  |             aop$FieldInfo_r_email = new FieldInfo(Class.forName("com.company.common.item.common.UserInfo"), 0, "email", 0xf2a8295678139d21L, this, true);
  |             addFieldReadInfo(aop$FieldInfo_r_email, collection);
  |             Object obj1 = null;
  |             aop$FieldInfo_r_home = new FieldInfo(Class.forName("com.company.common.item.common.UserInfo"), 1, "home", 0x5537394f14d81f41L, this, true);
  |             addFieldReadInfo(aop$FieldInfo_r_home, collection);
  |             Object obj2 = null;
  |             aop$FieldInfo_r_pageSize = new FieldInfo(Class.forName("com.company.common.item.common.UserInfo"), 2, "pageSize", 0x8f5f147f40d31e6dL, this, true);
  |             addFieldReadInfo(aop$FieldInfo_r_pageSize, collection);
  |             Object obj3 = null;
  |             aop$FieldInfo_r_startPage = new FieldInfo(Class.forName("com.company.common.item.common.UserInfo"), 3, "startPage", 0x423337f6036663e8L, this, true);
  | 
  | 
  | 	    ... truncated ...
  | 
  | 	}
  | 
  | 
  | 	// **** Example of Read Method pointcut ****
  | 	// this is from JAD so finally block are not shown but can be determined by the goto statements
  | 
  |         protected String getEmail99631339274670319(UserInfo userinfo) throws MMSException
  |         {
  |             aop$MethodInfo_getEmail99631339274670319.getInterceptorChainReadWriteLock().readLock().lock();
  |             String s;
  |             if(joinpoint_getEmail99631339274670319 == null && aop$MethodInfo_getEmail99631339274670319 != null && aop$MethodInfo_getEmail99631339274670319.hasAdvices())
  |                 super.generateJoinPointClass(aop$MethodInfo_getEmail99631339274670319);
  |             if(joinpoint_getEmail99631339274670319 == null)
  |             {
  |                 s = (String)userinfo.com$company$common$item$common$UserInfo$getEmail$aop();
  |             } else
  |             {
  |                 s = (String)joinpoint_getEmail99631339274670319.invokeJoinpoint(userinfo);
  |                 break MISSING_BLOCK_LABEL_123;
  |             }
  |               goto _L1
  | _L2:
  |             return s;
  | _L3:
  |             return s;
  |             Exception exception;
  |             exception;
  |             aop$MethodInfo_getEmail99631339274670319.getInterceptorChainReadWriteLock().readLock().unlock();
  |             throw exception;
  | _L1:
  |             aop$MethodInfo_getEmail99631339274670319.getInterceptorChainReadWriteLock().readLock().unlock();
  |               goto _L2
  |             aop$MethodInfo_getEmail99631339274670319.getInterceptorChainReadWriteLock().readLock().unlock();
  |               goto _L3
  |         }
  | 
  | 
  | 
  | 	// **** Example of Write Method Pointcut ****
  | 	// this is from JAD so finally block are not shown but can be determined by the goto statements
  | 
  |         protected void setEmail_N_4117224176847888539(UserInfo userinfo, Strings) throws MMSException
  |         {
  |             aop$MethodInfo_setEmail_N_4117224176847888539.getInterceptorChainReadWriteLock().readLock().lock();
  |             if(joinpoint_setEmail_N_4117224176847888539 == null && aop$MethodInfo_setEmail_N_4117224176847888539 != null && aop$MethodInfo_setEmail_N_4117224176847888539.hasAdvices())
  |                 super.generateJoinPointClass(aop$MethodInfo_setEmail_N_4117224176847888539);
  |             if(joinpoint_setEmail_N_4117224176847888539 == null)
  |                 userinfo.com$company$common$item$common$UserInfo$setEmail$aop(s);
  |             else
  |                 joinpoint_setEmail_N_4117224176847888539.invokeJoinpoint(userinfo, s);
  |             break MISSING_BLOCK_LABEL_97;
  |             Exception exception;
  |             exception;
  |             aop$MethodInfo_setEmail_N_4117224176847888539.getInterceptorChainReadWriteLock().readLock().unlock();
  |             throw exception;
  |             aop$MethodInfo_setEmail_N_4117224176847888539.getInterceptorChainReadWriteLock().readLock().unlock();
  |             return;
  |         }
  | 
  | 
  | 
  | 	//other set / get methods
  | 	... truncated ...
  | 
  | 


Any help would be great, I dont know how to get this condition to happen it just happens so any help or direction would be great.  Like I said before we did not see this occur in AOP 1.5.6 in JBoss 4.2.2 and our code did not change -- yet :) .

-Pete

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4213265#4213265

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4213265



More information about the jboss-user mailing list