From 580d9f81e244f1632ef42911a22460824e6ea809 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Fri, 5 Jan 2024 17:06:32 +0100 Subject: [PATCH] Polishing --- .../annotation/AutowiredAnnotationBeanPostProcessor.java | 8 ++++---- .../support/DependencyInjectionTestExecutionListener.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 9c7686d51cdb..c52bddcc6232 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2023 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -517,9 +517,9 @@ public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, Str } /** - * 'Native' processing method for direct calls with an arbitrary target instance, - * resolving all of its fields and methods which are annotated with one of the - * configured 'autowired' annotation types. + * Native processing method for direct calls with an arbitrary target + * instance, resolving all of its fields and methods which are annotated with + * one of the configured 'autowired' annotation types. * @param bean the target instance to process * @throws BeanCreationException if autowiring failed * @see #setAutowiredAnnotationTypes(Set) diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java index 2e24f435c63d..fef799f259c3 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java @@ -153,7 +153,7 @@ private void injectDependenciesInAotMode(TestContext testContext) throws Excepti } Object bean = testContext.getTestInstance(); - Class clazz = testContext.getTestClass(); + String beanName = testContext.getTestClass().getName() + AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX; ConfigurableListableBeanFactory beanFactory = gac.getBeanFactory(); AutowiredAnnotationBeanPostProcessor autowiredAnnotationBpp = new AutowiredAnnotationBeanPostProcessor(); @@ -162,7 +162,7 @@ private void injectDependenciesInAotMode(TestContext testContext) throws Excepti CommonAnnotationBeanPostProcessor commonAnnotationBpp = new CommonAnnotationBeanPostProcessor(); commonAnnotationBpp.setBeanFactory(beanFactory); commonAnnotationBpp.processInjection(bean); - beanFactory.initializeBean(bean, clazz.getName() + AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX); + beanFactory.initializeBean(bean, beanName); testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE); }