Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add repro project for SPR-9181

  • Loading branch information...
commit a696df347f67118f9f4b5f7c13a4a22d9b041a98 1 parent 88f748a
Stephan Andresen authored cbeams committed
View
73 SPR-9181/pom.xml
@@ -0,0 +1,73 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.springframework.issues</groupId>
+ <artifactId>SPR-9181</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <!-- Fails
+ <version>3.2.0.BUILD-SNAPSHOT</version>
+ -->
+ <version>3.1.1.RELEASE</version>
+ <!-- Works
+ <version>3.1.0.RELEASE</version>
+ -->
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>springsource</id>
+ <name>SpringSource Repository</name>
+ <url>http://repo.springsource.org/snapshot</url>
+ <snapshots><enabled>true</enabled></snapshots>
+ </repository>
+ </repositories>
+ <properties>
+ <project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.7.2</version>
+ <configuration>
+ <includes>
+ <include>**/*Tests.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*Abstract*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
View
24 SPR-9181/src/main/java/org/springframework/issues/Bar.java
@@ -0,0 +1,24 @@
+package org.springframework.issues;
+
+import org.springframework.context.annotation.Scope;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
+
+@Named
+@Scope(SCOPE_PROTOTYPE)
+public class Bar {
+
+ Foo foo;
+
+ @Inject
+ public Bar(@Named("testFactory") Foo foo){
+ this.foo = foo;
+ }
+
+ public Foo getFoo(){
+ return foo;
+ }
+}
View
20 SPR-9181/src/main/java/org/springframework/issues/Factory.java
@@ -0,0 +1,20 @@
+package org.springframework.issues;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.context.annotation.Scope;
+
+import javax.inject.Named;
+import javax.inject.Provider;
+
+import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
+
+@Named
+@Lazy(false)
+public class Factory {
+ @Bean
+ @Scope(SCOPE_PROTOTYPE)
+ public Foo testFactory(final Provider<ProviderClass> testProvider) {
+ return new Foo(testProvider);
+ }
+}
View
17 SPR-9181/src/main/java/org/springframework/issues/Foo.java
@@ -0,0 +1,17 @@
+package org.springframework.issues;
+
+import javax.inject.Provider;
+
+
+public class Foo {
+
+ Provider<ProviderClass> testProvider;
+
+ public Foo(Provider<ProviderClass> testProvider) {
+ this.testProvider = testProvider;
+ }
+
+ public ProviderClass getProviderClass(){
+ return testProvider.get();
+ }
+}
View
4 SPR-9181/src/main/java/org/springframework/issues/ProviderClass.java
@@ -0,0 +1,4 @@
+package org.springframework.issues;
+
+public interface ProviderClass {
+}
View
16 SPR-9181/src/main/java/org/springframework/issues/ProviderClassImpl.java
@@ -0,0 +1,16 @@
+package org.springframework.issues;
+
+import org.springframework.context.annotation.Scope;
+
+import javax.inject.Named;
+
+import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROTOTYPE;
+
+@Named
+@Scope(SCOPE_PROTOTYPE)
+public class ProviderClassImpl implements ProviderClass {
+
+ public ProviderClassImpl(){
+
+ }
+}
View
0  SPR-9181/src/main/resources/.gitignore
No changes.
View
28 SPR-9181/src/test/java/org/springframework/issues/ReproTests.java
@@ -0,0 +1,28 @@
+package org.springframework.issues;
+
+import org.junit.Test;
+import org.springframework.context.support.GenericXmlApplicationContext;
+
+/**
+ * Unit test that reproduces an issue reported against SPR JIRA. @Test methods within
+ * need not pass with the green bar! Rather they should fail in such a way that
+ * demonstrates the reported issue.
+ */
+public class ReproTests {
+
+ @Test
+ public void repro() {
+ GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
+ ctx.load("classpath:org/springframework/issues/ReproTests-context.xml");
+ ctx.refresh();
+
+ // First time works
+ Bar bar = ctx.getBean(Bar.class);
+ bar.getFoo().getProviderClass();
+
+ // Second call crashes
+ bar = ctx.getBean(Bar.class);
+ bar.getFoo().getProviderClass();
+ }
+
+}
View
7 SPR-9181/src/test/resources/log4j.properties
@@ -0,0 +1,7 @@
+log4j.rootCategory=ERROR, stdout
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
+
+log4j.category.org.springframework=WARN
View
15 SPR-9181/src/test/resources/org/springframework/issues/ReproTests-context.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:component-scan base-package="org.springframework.issues"/>
+
+</beans>
Please sign in to comment.
Something went wrong with that request. Please try again.