[jboss-cvs] JBossAS SVN: r61559 - projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 21 19:53:17 EDT 2007


Author: flavia.rainone at jboss.com
Date: 2007-03-21 19:53:17 -0400 (Wed, 21 Mar 2007)
New Revision: 61559

Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java
Log:
[JBAOP-37] Fixed bug related to selection of overloaded advices.

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java	2007-03-21 21:47:32 UTC (rev 61558)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/annotation/AdviceMethodFactory.java	2007-03-21 23:53:17 UTC (rev 61559)
@@ -527,8 +527,7 @@
          boolean isContextRule)
    {
       short bestDegree = NOT_ASSIGNABLE_DEGREE;
-      AdviceInfo bestAdvice = null;
-      Collection<AdviceInfo> removeList = new ArrayList<AdviceInfo>();
+      List<AdviceInfo> bestAdviceList = new ArrayList<AdviceInfo>();
       
       // rule i is more important than rule i + 1
       for (int i = 0; i < totalRules; i++)
@@ -541,27 +540,24 @@
                   isContextRule, properties);
             if (currentDegree < bestDegree)
             {
-               if (bestAdvice != null)
-               {
-                  removeList.add(bestAdvice);
-               }
-               bestAdvice = currentAdvice;
+               bestAdviceList.clear();
+               bestAdviceList.add(currentAdvice);
                bestDegree = currentDegree;
             }
-            else if (currentDegree > bestDegree)
+            else if (currentDegree == bestDegree)
             {
-               iterator.remove();
+            	bestAdviceList.add(currentAdvice);
             }
          }
          // found the best
-         if (greatestRank.size() - removeList.size() == 1)
+         if (bestAdviceList.size() == 1)
          {
-            return bestAdvice;
+            return bestAdviceList.get(0);
          }
-         greatestRank.removeAll(removeList);
+         greatestRank.clear();
+         greatestRank.addAll(bestAdviceList);
          // reset values
-         removeList.clear();
-         bestAdvice = null;
+         bestAdviceList.clear();
          bestDegree = NOT_ASSIGNABLE_DEGREE;
       }
       return null;




More information about the jboss-cvs-commits mailing list