-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
@ActiveProfiles with same profiles but different order results in duplicate ApplicationContext #25973
Closed
1 task done
Labels
in: test
Issues in the test module
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Comments
sbrannen
added a commit
that referenced
this issue
Oct 26, 2020
…rder Prior to this commit, two @activeprofiles declarations with the same profiles but different order resulted in an identical duplicate ApplicationContext in the context cache in the Spring TestContext Framework. This commit uses a TreeSet to ensure that registered active profiles are both unique and sorted, thereby avoiding cache misses for semantically identical active profiles configuration on different test classes. Closes gh-25973
3 tasks
izeye
added a commit
to izeye/spring-boot-throwaway-branches
that referenced
this issue
Nov 1, 2020
@activeprofiles doesn't seem to keep registration order of profiles since spring-projects/spring-framework#25973.
sbrannen
added a commit
that referenced
this issue
Nov 2, 2020
With this commit, bean definition profiles declared via @activeprofiles are once again stored in registration order, in order to support use cases in Spring Boot and other frameworks that depend on the registration order. This effectively reverts the changes made in conjunction with gh-25973. Closes gh-26004
sbrannen
added a commit
that referenced
this issue
Nov 2, 2020
With this commit, bean definition profiles declared via @activeprofiles are once again stored in registration order, in order to support use cases in Spring Boot and other frameworks that depend on the registration order. This effectively reverts the changes made in conjunction with gh-25973. Closes gh-26004
sbrannen
added a commit
that referenced
this issue
Nov 3, 2020
With this commit, bean definition profiles declared via @activeprofiles are once again stored in registration order, in order to support use cases in Spring Boot and other frameworks that depend on the registration order. This effectively reverts the changes made in conjunction with gh-25973. Closes gh-26004
zx20110729
pushed a commit
to zx20110729/spring-framework
that referenced
this issue
Feb 18, 2022
…rder Prior to this commit, two @activeprofiles declarations with the same profiles but different order resulted in an identical duplicate ApplicationContext in the context cache in the Spring TestContext Framework. This commit uses a TreeSet to ensure that registered active profiles are both unique and sorted, thereby avoiding cache misses for semantically identical active profiles configuration on different test classes. Closes spring-projectsgh-25973
zx20110729
pushed a commit
to zx20110729/spring-framework
that referenced
this issue
Feb 18, 2022
With this commit, bean definition profiles declared via @activeprofiles are once again stored in registration order, in order to support use cases in Spring Boot and other frameworks that depend on the registration order. This effectively reverts the changes made in conjunction with spring-projectsgh-25973. Closes spring-projectsgh-26004
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: test
Issues in the test module
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Overview
While working on #25800, I realized that two
@ActiveProfiles
declarations on different test classes using the same profiles but declared in a different order would result in the creation of a duplicate yet identicalApplicationContext
in the context cache in the Spring TestContext Framework. This is becauseActiveProfilesUtils
stores the active profiles in aLinkedHashSet
to preserve registration order. The set is then converted to aString[]
which is handed off toMergedContextConfiguration
which also uses aLinkedHashSet
to ensure uniqueness but still retains the registration order of the active profiles. When theMergedContextConfiguration
is used as the context cache key to check whether anApplicationContext
already exists for the given metadata, the implementation ofequals()
inMergedContextConfiguration
usesArrays.equals()
to compare two sets of active profiles, and that results in a cache miss for semantically identical active profile arrays{ apples, oranges }
and{ oranges, apples }
. Consequently, an identicalApplicationContext
is created and stored in the context cache when that should not be the case.Deliverables
MergedContextConfiguration
in order to avoid context cache misses.The text was updated successfully, but these errors were encountered: