-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix infinite recursion bug in nested @configuration
Prior to this commit, an infinite recursion would occur if a @configuration class were nested within its superclass, e.g. abstract class Parent { @configuration static class Child extends Parent { ... } } This is because the processing of the nested class automatically checks the superclass hierarchy for certain reasons, and each superclass is in turn checked for nested @configuration classes. The ConfigurationClassParser implementation now prevents this by keeping track of known superclasses, i.e. once a superclass has been processed, it is never again checked for nested classes, etc. Issue: SPR-8955
- Loading branch information
Showing
3 changed files
with
99 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...test/java/org/springframework/context/annotation/configuration/spr8955/Spr8955Parent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2002-2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.context.annotation.configuration.spr8955; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* @author Chris Beams | ||
* @author Willem Dekker | ||
*/ | ||
abstract class Spr8955Parent { | ||
|
||
@Component | ||
static class Spr8955Child extends Spr8955Parent { | ||
|
||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
.../test/java/org/springframework/context/annotation/configuration/spr8955/Spr8955Tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2002-2012 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.context.annotation.configuration.spr8955; | ||
|
||
import org.junit.Test; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
|
||
|
||
/** | ||
* @author Chris Beams | ||
* @author Willem Dekker | ||
*/ | ||
public class Spr8955Tests { | ||
|
||
@Test | ||
public void repro() { | ||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); | ||
ctx.scan("org.springframework.context.annotation.configuration.spr8955"); | ||
ctx.refresh(); | ||
} | ||
|
||
} |