Skip to content
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

@Import in another annotation still results in double scan [SPR-12334] #16939

Closed
spring-projects-issues opened this issue Oct 14, 2014 · 7 comments
Closed
Assignees
Labels
in: core type: bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Oct 14, 2014

Alex Pogrebnyak opened SPR-12334 and commented

Please reopen this issue -> #15546

It claims that it is fixed in 3.2.5, but I am able to reproduce it with 3.2.8.RELEASE


Affects: 3.2.8

Issue Links:

  • #15546 Duplicate scan of @Import annotations when inherited from another annotation
  • #17047 When use the same configuration annotation of javaconfig, does not work on spring 3.2.12
@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 21, 2014

Juergen Hoeller commented

As Phil Webb asked on #15546, please create a fresh test case for this which actually fails on 3.2.8 (or preferably 3.2.11)...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 21, 2014

Alex Pogrebnyak commented

Self-contained test below. On my system 2 lines are printed when test is ran.

package test.spr12334;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class Spr12334
{

    @Import(TestImport.class)
    public @interface AnotherImport {
    }

    @Configuration
    @AnotherImport
    public static class TestConfiguration {
    }

    public static class TestImport implements ImportBeanDefinitionRegistrar {
        @Override
        public void registerBeanDefinitions(
                final AnnotationMetadata anImport,
                final BeanDefinitionRegistry aRegistry
            )
        {
            System.out.println("I am scanned twice!");
        }
    }

    public static void main ( final String[] args )
    {

        final AnnotationConfigApplicationContext context =
            new AnnotationConfigApplicationContext( );

        context.scan(  TestImport.class.getPackage( ).getName( ) );

        context.refresh( );

        context.getBean( TestConfiguration.class );

        context.close( );
    }
}

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 21, 2014

Juergen Hoeller commented

Thanks, that helps. The test passes against 4.1.2; I'll backport it to 4.0.8 and 3.2.12, expecting it to fail only in the 3.2.x line.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 21, 2014

Juergen Hoeller commented

Fixed in 3.2.12 through extra tracking of ImportBeanDefinitionRegistrar classes that have been processed already. This is available in the upcoming 3.2.12.BUILD-SNAPSHOT (see http://projects.spring.io/spring-framework/) in the meantime. Would be great if you could give it a try...

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Oct 22, 2014

Alex Pogrebnyak commented

Verified FIXED in 3.2.12.BUILD-SNAPSHOT
Verified FIXED in 4.1.1.RELEASE

-Alex

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 22, 2014

Juergen Hoeller commented

Alex, I had to revise the fix due to a regression caused in 3.2.12 (see #17047): We're now finding duplicates at the collectImports level.

This will be available in the upcoming 3.2.13 snapshot... Please give it a try once more - it would be great to know whether this variant works for you as well!

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Dec 5, 2014

Alex Pogrebnyak commented

Verified FIXED in 3.2.13.BUILD-SNAPSHOT (Snapshot label BUILD-20141124.181259-4)

-Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants