Skip to content

SimpleAliasRegistry.canonicalName can produce an endless loop [SPR-7274] #11933

@spring-projects-issues

Description

@spring-projects-issues

Joern Huxhorn opened SPR-7274 and commented

The corresponding stacktrace looks like this:

"main" prio=5 tid=102800800 nid=0x100501000 runnable [1004ff000]
java.lang.Thread.State: RUNNABLE
at org.springframework.core.SimpleAliasRegistry.canonicalName(SimpleAliasRegistry.java:156)
at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:966)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1317)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)

  • locked <107d35848> (a java.util.concurrent.ConcurrentHashMap)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
  • locked <107d35a40> (a java.util.concurrent.ConcurrentHashMap)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
  • locked <107d06848> (a java.lang.Object)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)

The endless loop is in line 156:
/**

  • Determine the raw name, resolving aliases to canonical names.
  • @param name the user-specified name
  • @return the transformed name
    */
    public String canonicalName(String name) {
    String canonicalName = name;
    // Handle aliasing.
    String resolvedName = null;
    do {
    resolvedName = this.aliasMap.get(canonicalName);
    if (resolvedName != null) {
    canonicalName = resolvedName;
    }
    }
    while (resolvedName != null); // <= here
    return canonicalName;
    }

I have this hang in a quite complex config file and I guess that there is some kind of alias loop. This, however, shouldn't result in an endless loop but in some useful error message containing the "loop path" of the aliases.


Affects: 3.0.2

Referenced from: commits 11330ba

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions