Project: AspectJ
Bug 269867 Non synchronized access to WeakHashMap causes infinite loop
Reported: 2009-03-24 14:16:04 | Status: resolved fixed

The non synchronized access from AjTypeSystem.getAjType(clazz) to a static instance of WeakHashMap may cause an infinite loop at start up in a multi threaded system. The thread dump shows that 32 of 33 threads of the application stuck in WeakHashMap.get(Object) line 355: "BundleStarterThreadQcCtrl24" prio=3 tid=0x00957c00 nid=0x39 runnable [0xd42fb000..0xd42ffa70] java.lang.Thread.State: RUNNABLE at java.util.WeakHashMap.get(WeakHashMap.java:355) at org.aspectj.lang.reflect.AjTypeSystem.getAjType(AjTypeSystem.java:37) at org.aspectj.weaver.reflect.Java15ReflectionBasedReferenceTypeDelegate.initialize(Java15ReflectionBasedReferenceTypeDelegate.java:66) at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.create15Delegate(ReflectionBasedReferenceTypeDelegateFactory.java:56) at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.createDelegate(ReflectionBasedReferenceTypeDelegateFactory.java:42) at org.aspectj.weaver.reflect.ReflectionWorld.resolveDelegate(ReflectionWorld.java:111) at org.aspectj.weaver.World.resolveToReferenceType(World.java:388) at org.aspectj.weaver.World.resolve(World.java:279) at org.aspectj.weaver.World.resolve(World.java:199) at org.aspectj.weaver.World.resolve(World.java:348) at org.aspectj.weaver.reflect.ReflectionWorld.resolve(ReflectionWorld.java:103) at org.aspectj.weaver.reflect.ReflectionWorld.resolve(ReflectionWorld.java:93) at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.toResolvedTypeArray(ReflectionBasedReferenceTypeDelegateFactory.java:214) at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.createResolvedMethod(ReflectionBasedReferenceTypeDelegateFactory.java:107) at org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateFactory.createResolvedMember(ReflectionBasedReferenceTypeDelegateFactory.java:98) at org.aspectj.weaver.reflect.ReflectionShadow.makeExecutionShadow(ReflectionShadow.java:53) at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesExecution(PointcutExpressionImpl.java:100) at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(PointcutExpressionImpl.java:92) at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:370)

Files changed in fix:
aspectj5rt/java5-src/org/aspectj/lang/reflect/AjTypeSystem.java