Skip to content

Regression: AnnotationScopeMetadataResolver fails to resolve VaadinView [SPR-13239] #17830

Closed

Description

@spring-projects-issues

Michal Kytýr opened SPR-13239 and commented

We are using the spring-vaadin library in our project, which has its own annotation @VaadinView:

@Target({java.lang.annotation.ElementType.TYPE})
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Documented
@VaadinComponent
@VaadinViewScope
public @interface VaadinView {

    /**
     * The name of the view. This is the name that is to be passed to the
     * {@link com.vaadin.navigator.Navigator} when navigating to the view. There can be multiple views
     * with the same name as long as they belong to separate UI subclasses.
     *
     * @see #ui()
     */
    String name();

    /**
     * By default, the view will be available for all UI subclasses in the application. This attribute can be used
     * to explicitly specify which subclass (or subclasses) that the view belongs to.
     */
    Class<? extends UI>[] ui() default {};
}

Library also defines its own scope "vaadin-view", which has a "shortcut" annotation @VaadinViewScope defined like:

@Scope("vaadin-view")
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface VaadinViewScope {
}

I tried our project with 4.2.0.RC2 (RC1 worked fine) and suddenly there is an exception when scanning scope of classes with @VaadinView annotation:

Caused by: org.springframework.core.annotation.AnnotationConfigurationException: In annotation [org.springframework.context.annotation.Scope] declared on [file [D:\...\AdminViewImpl.class]], attribute [value] and its alias [name] are present with values of [vaadin-view] and [admin], but only one is permitted.
	at org.springframework.core.annotation.AnnotationAttributes.getRequiredAttributeWithAlias(AnnotationAttributes.java:434)
	at org.springframework.core.annotation.AnnotationAttributes.getAliasedString(AnnotationAttributes.java:149)
	at org.springframework.context.annotation.AnnotationScopeMetadataResolver.resolveScopeMetadata(AnnotationScopeMetadataResolver.java:82)
	at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:250)
	at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:137)
	at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:267)
	at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231)
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198)
	at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167)
	... 18 more

I think it has something to do with #16020, parameters "name" and "value" of different annotations are mixed together.


Affects: 4.2 RC2

Issue Links:

Referenced from: commits 9f15f34

Activity

  1. spring-projects-issues commented on Jul 16, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    This an an unfortunate side effect: VaadinView's name attribute by convention overrides the newly introduced name attribute on @Scope now, which of course it doesn't intend to. We either need to remove/rename that new attribute on @Scope, or find some rules for how a common name attribute does not automatically override here.

    Juergen

  2. spring-projects-issues commented on Jul 17, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    I've renamed @Scope's new attribute to scopeName, avoiding the immediate conflict with innocent name attributes on composed annotations.

    Juergen

  3. added
    type: bug
    in: core
    on Jan 11, 2019
  4. added this to the 4.2 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions