|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2022 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.
|
@@ -43,6 +43,7 @@ public abstract class AopTestUtils {
|
43 | 43 | * {@linkplain AopUtils#isAopProxy proxy}, the target of the proxy will
|
44 | 44 | * be returned; otherwise, the {@code candidate} will be returned
|
45 | 45 | * <em>as is</em>.
|
| 46 | + * @param <T> the type of the target object |
46 | 47 | * @param candidate the instance to check (potentially a Spring AOP proxy;
|
47 | 48 | * never {@code null})
|
48 | 49 | * @return the target object or the {@code candidate} (never {@code null})
|
@@ -75,11 +76,18 @@ public static <T> T getTargetObject(Object candidate) {
|
75 | 76 | * {@linkplain AopUtils#isAopProxy proxy}, the ultimate target of all
|
76 | 77 | * nested proxies will be returned; otherwise, the {@code candidate}
|
77 | 78 | * will be returned <em>as is</em>.
|
| 79 | + * <p>NOTE: If the top-level proxy or a nested proxy is not backed by a |
| 80 | + * {@linkplain org.springframework.aop.TargetSource#isStatic() static} |
| 81 | + * {@link org.springframework.aop.TargetSource TargetSource}, invocation of |
| 82 | + * this utility method may result in undesired behavior such as infinite |
| 83 | + * recursion leading to a {@link StackOverflowError}. |
| 84 | + * @param <T> the type of the target object |
78 | 85 | * @param candidate the instance to check (potentially a Spring AOP proxy;
|
79 | 86 | * never {@code null})
|
80 | 87 | * @return the target object or the {@code candidate} (never {@code null})
|
81 | 88 | * @throws IllegalStateException if an error occurs while unwrapping a proxy
|
82 | 89 | * @see Advised#getTargetSource()
|
| 90 | + * @see org.springframework.aop.TargetSource#isStatic() |
83 | 91 | * @see org.springframework.aop.framework.AopProxyUtils#ultimateTargetClass
|
84 | 92 | */
|
85 | 93 | @SuppressWarnings("unchecked")
|
|
0 commit comments