mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-17 08:24:13 +00:00
Use empty array constants instead of repeatedly creating new ones
Closes gh-35660 Signed-off-by: Kamil Krzywański <kamilkrzywanski01@gmail.com> Signed-off-by: Kamil Krzywanski <kamilkrzywanski01@gmail.com>
This commit is contained in:
committed by
Sam Brannen
parent
687bc7652d
commit
948367092c
@@ -76,7 +76,8 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
* supplied by the advisors.
|
||||
*/
|
||||
public static final TargetSource EMPTY_TARGET_SOURCE = EmptyTargetSource.INSTANCE;
|
||||
|
||||
/** Empty advisor array constant. */
|
||||
public static final Advisor[] EMPTY_ADVISORS = new Advisor[0];
|
||||
|
||||
/** Package-protected to allow direct access for efficiency. */
|
||||
@SuppressWarnings("serial")
|
||||
@@ -288,7 +289,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
|
||||
|
||||
@Override
|
||||
public final Advisor[] getAdvisors() {
|
||||
return this.advisors.toArray(new Advisor[0]);
|
||||
return this.advisors.toArray(EMPTY_ADVISORS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -39,6 +39,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Serializable {
|
||||
private static final MethodInterceptor [] EMPTY_INTERCEPTOR_ARRAY = new MethodInterceptor[0];
|
||||
|
||||
private final List<AdvisorAdapter> adapters = new ArrayList<>(3);
|
||||
|
||||
@@ -89,7 +90,7 @@ public class DefaultAdvisorAdapterRegistry implements AdvisorAdapterRegistry, Se
|
||||
if (interceptors.isEmpty()) {
|
||||
throw new UnknownAdviceTypeException(advisor.getAdvice());
|
||||
}
|
||||
return interceptors.toArray(new MethodInterceptor[0]);
|
||||
return interceptors.toArray(EMPTY_INTERCEPTOR_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user