@@ -348,29 +348,36 @@ private void bindParameters(ProxyMethodInvocation invocation, JoinPointMatch jpm
348
348
}
349
349
350
350
private ShadowMatch getShadowMatch (Method targetMethod , Method originalMethod ) {
351
+ // Avoid lock contention for known Methods through concurrent access...
351
352
ShadowMatch shadowMatch = this .shadowMatchCache .get (targetMethod );
352
353
if (shadowMatch == null ) {
353
- try {
354
- shadowMatch = this .pointcutExpression .matchesMethodExecution (targetMethod );
355
- }
356
- catch (ReflectionWorld .ReflectionWorldException ex ) {
357
- // Failed to introspect target method, probably because it has been loaded
358
- // in a special ClassLoader. Let's try the original method instead...
359
- if (targetMethod == originalMethod ) {
360
- shadowMatch = new ShadowMatchImpl (org .aspectj .util .FuzzyBoolean .NO , null , null , null );
361
- }
362
- else {
354
+ synchronized (this .shadowMatchCache ) {
355
+ // Not found - now check again with full lock...
356
+ shadowMatch = this .shadowMatchCache .get (targetMethod );
357
+ if (shadowMatch == null ) {
363
358
try {
364
- shadowMatch = this .pointcutExpression .matchesMethodExecution (originalMethod );
359
+ shadowMatch = this .pointcutExpression .matchesMethodExecution (targetMethod );
365
360
}
366
- catch (ReflectionWorld .ReflectionWorldException ex2 ) {
367
- // Could neither introspect the target class nor the proxy class ->
368
- // let's simply consider this method as non-matching.
369
- shadowMatch = new ShadowMatchImpl (org .aspectj .util .FuzzyBoolean .NO , null , null , null );
361
+ catch (ReflectionWorld .ReflectionWorldException ex ) {
362
+ // Failed to introspect target method, probably because it has been loaded
363
+ // in a special ClassLoader. Let's try the original method instead...
364
+ if (targetMethod == originalMethod ) {
365
+ shadowMatch = new ShadowMatchImpl (org .aspectj .util .FuzzyBoolean .NO , null , null , null );
366
+ }
367
+ else {
368
+ try {
369
+ shadowMatch = this .pointcutExpression .matchesMethodExecution (originalMethod );
370
+ }
371
+ catch (ReflectionWorld .ReflectionWorldException ex2 ) {
372
+ // Could neither introspect the target class nor the proxy class ->
373
+ // let's simply consider this method as non-matching.
374
+ shadowMatch = new ShadowMatchImpl (org .aspectj .util .FuzzyBoolean .NO , null , null , null );
375
+ }
376
+ }
370
377
}
378
+ this .shadowMatchCache .put (targetMethod , shadowMatch );
371
379
}
372
380
}
373
- this .shadowMatchCache .put (targetMethod , shadowMatch );
374
381
}
375
382
return shadowMatch ;
376
383
}
0 commit comments