Skip to content

Update Javadoc for ignoreDependencyInterface() in AbstractAutowireCapableBeanFactory #34747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

iggzq
Copy link
Contributor

@iggzq iggzq commented Apr 13, 2025

Specifically, the documentation update reflects that:

  • Initially, it was mentioned that only the BeanFactoryAware interface is ignored by default.
  • The updated documentation now correctly states that BeanNameAware, BeanFactoryAware, and BeanClassLoaderAware interfaces are all ignored by default.

We can understand from the default constructor of AbstractAutowireCapableBeanFactory that:

/**
* Create a new AbstractAutowireCapableBeanFactory.
*/
public AbstractAutowireCapableBeanFactory() {
	super();
	ignoreDependencyInterface(BeanNameAware.class);
	ignoreDependencyInterface(BeanFactoryAware.class);
	ignoreDependencyInterface(BeanClassLoaderAware.class);
	this.instantiationStrategy = new CglibSubclassingInstantiationStrategy();
}

…yInterface` method in the `AbstractAutowireCapableBeanFactory` class. The updated documentation now indicates that by default, the interfaces ignored are not only `BeanFactoryAware`, but also include `BeanNameAware`, `BeanFactoryAware`, and `BeanClassLoaderAware`.

Specifically, the documentation update reflects that:
- Initially, it was mentioned that only the `BeanFactoryAware` interface is ignored by default.
- The updated documentation now correctly states that `BeanNameAware`, `BeanFactoryAware`, and `BeanClassLoaderAware` interfaces are all ignored by default.

This change ensures a more accurate representation of the default behavior regarding which dependency interfaces are automatically ignored during autowiring in the context of Spring's bean factory mechanism.

Signed-off-by: lituizi <2811328244@qq.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Apr 13, 2025
@iggzq
Copy link
Contributor Author

iggzq commented Apr 13, 2025

The comment of the method ignoreDependencyInterface in AbstractAutowireCapableBeanFactory.java.:

	/**
	 * Ignore the given dependency interface for autowiring.
	 * <p>This will typically be used by application contexts to register
	 * dependencies that are resolved in other ways, like BeanFactory through
	 * BeanFactoryAware or ApplicationContext through ApplicationContextAware.
	 * <p>By default, only the BeanFactoryAware interface is ignored.
	 * For further types to ignore, invoke this method for each type.
	 * @see org.springframework.beans.factory.BeanFactoryAware
	 * @see org.springframework.context.ApplicationContextAware
	 */
	public void ignoreDependencyInterface(Class<?> ifc) {
		this.ignoredDependencyInterfaces.add(ifc);
	}

Based on all the constructors of AbstractAutowireCapableBeanFactory, we can find that the comment here is incorrect.

@sbrannen sbrannen self-assigned this Apr 14, 2025
@sbrannen sbrannen added type: documentation A documentation task in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Apr 14, 2025
@sbrannen sbrannen added this to the 6.2.6 milestone Apr 14, 2025
@sbrannen sbrannen changed the title Correct wrong docs(spring-beans): Update the documentation for the 'ignoreDependencyInterface method' Update Javadoc for ignoreDependencyInterface() in AbstractAutowireCapableBeanFactory Apr 14, 2025
sbrannen added a commit that referenced this pull request Apr 14, 2025
@sbrannen sbrannen closed this in bb45a3a Apr 14, 2025
@sbrannen
Copy link
Member

Hi @iggzq,

Congratulations on submitting your first PR for the Spring Framework! 👍

This has been merged in bb45a3a and revised in d0966df.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: documentation A documentation task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants