Browse Source

Merge remote-tracking branch 'origin/2.2.x'

pull/985/head
Olga MaciaszekSharma 3 years ago
parent
commit
a23bdb8845
  1. 9
      spring-cloud-context/src/main/java/org/springframework/cloud/util/ProxyUtils.java

9
spring-cloud-context/src/main/java/org/springframework/cloud/util/ProxyUtils.java

@ -18,6 +18,7 @@ package org.springframework.cloud.util; @@ -18,6 +18,7 @@ package org.springframework.cloud.util;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.util.Assert;
/**
* @author Ryan Baxter
@ -30,9 +31,13 @@ public final class ProxyUtils { @@ -30,9 +31,13 @@ public final class ProxyUtils {
@SuppressWarnings("unchecked")
public static <T> T getTargetObject(Object candidate) {
Assert.notNull(candidate, "Candidate must not be null");
try {
if (AopUtils.isAopProxy(candidate) && (candidate instanceof Advised)) {
return (T) ((Advised) candidate).getTargetSource().getTarget();
if (AopUtils.isAopProxy(candidate) && candidate instanceof Advised) {
Object target = ((Advised) candidate).getTargetSource().getTarget();
if (target != null) {
return (T) getTargetObject(target);
}
}
}
catch (Exception ex) {

Loading…
Cancel
Save