|
1 | 1 | /* |
2 | | - * Copyright 2002-2012 the original author or authors. |
| 2 | + * Copyright 2002-2013 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
16 | 16 |
|
17 | 17 | package org.springframework.aop.aspectj.autoproxy; |
18 | 18 |
|
| 19 | +import java.util.ArrayList; |
19 | 20 | import java.util.Comparator; |
20 | | -import java.util.LinkedList; |
21 | 21 | import java.util.List; |
22 | 22 |
|
23 | 23 | import org.aopalliance.aop.Advice; |
@@ -67,29 +67,24 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx |
67 | 67 | @Override |
68 | 68 | @SuppressWarnings("unchecked") |
69 | 69 | protected List<Advisor> sortAdvisors(List<Advisor> advisors) { |
70 | | - // build list for sorting |
71 | 70 | List<PartiallyComparableAdvisorHolder> partiallyComparableAdvisors = |
72 | | - new LinkedList<PartiallyComparableAdvisorHolder>(); |
| 71 | + new ArrayList<PartiallyComparableAdvisorHolder>(advisors.size()); |
73 | 72 | for (Advisor element : advisors) { |
74 | 73 | partiallyComparableAdvisors.add( |
75 | 74 | new PartiallyComparableAdvisorHolder(element, DEFAULT_PRECEDENCE_COMPARATOR)); |
76 | 75 | } |
77 | | - |
78 | | - // sort it |
79 | 76 | List<PartiallyComparableAdvisorHolder> sorted = |
80 | 77 | PartialOrder.sort(partiallyComparableAdvisors); |
81 | | - if (sorted == null) { |
82 | | - // TODO: work harder to give a better error message here. |
83 | | - throw new IllegalArgumentException("Advice precedence circularity error"); |
| 78 | + if (sorted != null) { |
| 79 | + List<Advisor> result = new ArrayList<Advisor>(advisors.size()); |
| 80 | + for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) { |
| 81 | + result.add(pcAdvisor.getAdvisor()); |
| 82 | + } |
| 83 | + return result; |
84 | 84 | } |
85 | | - |
86 | | - // extract results again |
87 | | - List<Advisor> result = new LinkedList<Advisor>(); |
88 | | - for (PartiallyComparableAdvisorHolder pcAdvisor : sorted) { |
89 | | - result.add(pcAdvisor.getAdvisor()); |
| 85 | + else { |
| 86 | + return super.sortAdvisors(advisors); |
90 | 87 | } |
91 | | - |
92 | | - return result; |
93 | 88 | } |
94 | 89 |
|
95 | 90 | /** |
|
0 commit comments