title: Test with Spring annotations causes ClosedByInterruptException when executed in maven test run
body: <p>I have a test class which looks like this:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = TestClass.TestConfig.class)
  public class TestClass{
  
      @Configuration
      @EnableAspectJAutoProxy
      @ComponentScan(basePackages = "package.with.dummy.provider.and.aspect", includeFilters = { 
              @Filter(Aspect.class), @Filter(Provider.class) })
      public static class TestConfig {
  
          @Bean
          CustomApplicationListener listener() {
              return new CustomApplicationListener ();
          }
  
      }
  
      @Autowired
      CustomApplicationListener listener;
  
      @Test
      public void testMethod() {
          // Do something with the listener
      }    
  }
  </code></pre>
  
  <p>When I run it with JUnit from Eclipse, it works just fine. But when the test is executed in my maven build/test cycle, it fails with the following exception:</p>
  
  <pre><code>java.lang.IllegalStateException: Failed to load ApplicationContext
       at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
  [...]
  Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [Path\To\Aspect\DummyAspect.class]; nested exception is java.nio.channels.ClosedByInterruptException
       at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:454)
  [...]
  Caused by: java.nio.channels.ClosedByInterruptException
       [java]     at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:220)
       [java]     at sun.nio.ch.FileChannelImpl.size(FileChannelImpl.java:327)
       [java]     at sun.nio.ch.ChannelInputStream.available(ChannelInputStream.java:128)
       [java]     at java.io.BufferedInputStream.available(BufferedInputStream.java:421)
       [java]     at org.springframework.asm.ClassReader.readClass(ClassReader.java:479)
       [java]     at org.springframework.asm.ClassReader.&lt;init&gt;(ClassReader.java:445)
       [java]     at org.springframework.core.type.classreading.SimpleMetadataReader.&lt;init&gt;(SimpleMetadataReader.java:54)
       [java]     at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
       [java]     at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
       [java]     at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:430)
  </code></pre>
  
  <p>I'd like to know the differences in executing tests from Eclipse vs from maven which may cause the observed situation to happen.</p>
  
  <p><s><strong>Update</strong>
  When removing <code>basePackages = "package.with.dummy.provider.and.aspect"</code> from the <code>@ComponentScan</code> annotation, everything works as expected! The package path is correct though. Now if someone could explain why this happens... </s></p>
  
  <p><strong>Update 2</strong>
  Well looks like it's even stranger. After some more tests I can confirm that the test passes <em>once</em> whenever I change the value of <code>basePackages</code>. After the first update where I removed the value and the test passed ran, it failed the text time and every time after that. I then tried to change the value to <code>package.with.dummy.provider.and</code>, removing one level, and it passed - once. Sounds like maybe some files generated by maven in the build and test process are not properly cleaned up, therefore the <code>@ComponentScan</code> finds and tries to read the files multiple times which causes the <code>ClosedByInterruptException</code>. </p>