"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-test/src/main/java/org/springframework/test/util/AopTestUtils.java" between
spring-framework-5.3.23.tar.gz and spring-framework-5.3.24.tar.gz

About: Spring Framework is an application framework for the Java platform and .NET Framework. Community edition.

AopTestUtils.java  (spring-framework-5.3.23):AopTestUtils.java  (spring-framework-5.3.24)
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skipping to change at line 46 skipping to change at line 46
* @see ReflectionTestUtils * @see ReflectionTestUtils
*/ */
public abstract class AopTestUtils { public abstract class AopTestUtils {
/** /**
* Get the <em>target</em> object of the supplied {@code candidate} objec t. * Get the <em>target</em> object of the supplied {@code candidate} objec t.
* <p>If the supplied {@code candidate} is a Spring * <p>If the supplied {@code candidate} is a Spring
* {@linkplain AopUtils#isAopProxy proxy}, the target of the proxy will * {@linkplain AopUtils#isAopProxy proxy}, the target of the proxy will
* be returned; otherwise, the {@code candidate} will be returned * be returned; otherwise, the {@code candidate} will be returned
* <em>as is</em>. * <em>as is</em>.
* @param <T> the type of the target object
* @param candidate the instance to check (potentially a Spring AOP proxy ; * @param candidate the instance to check (potentially a Spring AOP proxy ;
* never {@code null}) * never {@code null})
* @return the target object or the {@code candidate} (never {@code null} ) * @return the target object or the {@code candidate} (never {@code null} )
* @throws IllegalStateException if an error occurs while unwrapping a pr oxy * @throws IllegalStateException if an error occurs while unwrapping a pr oxy
* @see Advised#getTargetSource() * @see Advised#getTargetSource()
* @see #getUltimateTargetObject * @see #getUltimateTargetObject
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T getTargetObject(Object candidate) { public static <T> T getTargetObject(Object candidate) {
Assert.notNull(candidate, "Candidate must not be null"); Assert.notNull(candidate, "Candidate must not be null");
skipping to change at line 78 skipping to change at line 79
} }
/** /**
* Get the ultimate <em>target</em> object of the supplied {@code candida te} * Get the ultimate <em>target</em> object of the supplied {@code candida te}
* object, unwrapping not only a top-level proxy but also any number of * object, unwrapping not only a top-level proxy but also any number of
* nested proxies. * nested proxies.
* <p>If the supplied {@code candidate} is a Spring * <p>If the supplied {@code candidate} is a Spring
* {@linkplain AopUtils#isAopProxy proxy}, the ultimate target of all * {@linkplain AopUtils#isAopProxy proxy}, the ultimate target of all
* nested proxies will be returned; otherwise, the {@code candidate} * nested proxies will be returned; otherwise, the {@code candidate}
* will be returned <em>as is</em>. * will be returned <em>as is</em>.
* <p>NOTE: If the top-level proxy or a nested proxy is not backed by a
* {@linkplain org.springframework.aop.TargetSource#isStatic() static}
* {@link org.springframework.aop.TargetSource TargetSource}, invocation
of
* this utility method may result in undesired behavior such as infinite
* recursion leading to a {@link StackOverflowError}.
* @param <T> the type of the target object
* @param candidate the instance to check (potentially a Spring AOP proxy ; * @param candidate the instance to check (potentially a Spring AOP proxy ;
* never {@code null}) * never {@code null})
* @return the target object or the {@code candidate} (never {@code null} ) * @return the target object or the {@code candidate} (never {@code null} )
* @throws IllegalStateException if an error occurs while unwrapping a pr oxy * @throws IllegalStateException if an error occurs while unwrapping a pr oxy
* @see Advised#getTargetSource() * @see Advised#getTargetSource()
* @see org.springframework.aop.TargetSource#isStatic()
* @see org.springframework.aop.framework.AopProxyUtils#ultimateTargetCla ss * @see org.springframework.aop.framework.AopProxyUtils#ultimateTargetCla ss
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T getUltimateTargetObject(Object candidate) { public static <T> T getUltimateTargetObject(Object candidate) {
Assert.notNull(candidate, "Candidate must not be null"); Assert.notNull(candidate, "Candidate must not be null");
try { try {
if (AopUtils.isAopProxy(candidate) && candidate instanceo f Advised) { if (AopUtils.isAopProxy(candidate) && candidate instanceo f Advised) {
Object target = ((Advised) candidate).getTargetSo urce().getTarget(); Object target = ((Advised) candidate).getTargetSo urce().getTarget();
if (target != null) { if (target != null) {
return (T) getUltimateTargetObject(target ); return (T) getUltimateTargetObject(target );
 End of changes. 4 change blocks. 
1 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)