Skip to content

IllegalArgumentException when overriding empty 'excludeFilters' array on @ComponentScan #22405

Closed

Description

@ogmios-voice

Affects: 5.1.4.RELEASE

(Similar to #16681) When you override excludeFilters in @ComponentScan with multiple Filters, an IllegalArgumentException will be thrown. (It works correctly in Spring Framework 4 (>=4.0.7).) Excerpt:

@Configuration
@ComponentScan(basePackages = "a", excludeFilters = {}) // can be empty
public class Cfg1 {}

@ComponentScan(basePackages = { "a", "b" }, excludeFilters = {
        @Filter(type = FilterType.REGEX, pattern = "c"),
        @Filter(type = FilterType.REGEX, pattern = "d")
    })
public class Cfg2 extends Cfg1 {}

The current "result":

java.lang.IllegalStateException: Failed to load ApplicationContext
    ...
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [...]; nested exception is java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected in attributes for annotation [org.springframework.context.annotation.ComponentScan]
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:315)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:232)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:95)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:691)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
    ...
Caused by: java.lang.IllegalArgumentException: Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected in attributes for annotation [org.springframework.context.annotation.ComponentScan]
    at org.springframework.core.annotation.AnnotationAttributes.assertAttributeType(AnnotationAttributes.java:365)
    at org.springframework.core.annotation.AnnotationAttributes.getRequiredAttribute(AnnotationAttributes.java:345)
    at org.springframework.core.annotation.AnnotationAttributes.getAnnotationArray(AnnotationAttributes.java:295)
    at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:101)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:287)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:295)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:242)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
    ...

Activity

  1. added
    status: waiting-for-triage
    on Feb 11, 2019
  2. self-assigned this
    on Feb 11, 2019
  3. added
    type: regression
    and removed
    status: waiting-for-triage
    on Feb 11, 2019
  4. added this to the 5.1.5 milestone on Feb 11, 2019
  5. changed the title [-]Attribute 'excludeFilters' is of type [Filter[]], but [AnnotationAttributes[]] was expected in attributes for annotation [org.springframework.context.annotation.ComponentScan][/-] [+]IllegalArgumentException when overriding empty 'excludeFilters' array on @ComponentScan[/+] on Feb 12, 2019
  6. added a commit that references this issue on Feb 12, 2019
    8637540
  7. added
    status: backported
    and removed on Feb 12, 2019
  8. added a commit that references this issue on Feb 12, 2019
    12b601f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: backportedtype: regression

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions