-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Profile activation: not operator does not work consistently [SPR-16465] #21010
Comments
Pushkar Prakash commented To explain it a bit more: AbstractEnvironment.acceptsProfiles() method fails to handle the above case. |
Juergen Hoeller commented This works as designed as far as I can tell: Each of the specified elements is evaluated individually, and the profile condition overall matches if one the element matches. So for "!p1,!p2", it matches for no profile active, for p1 only active, for p2 only active, but not for p1 and p2 active (since both "!p1" and "!p2" do not match in such a scenario). |
Pushkar Prakash commented I thought the same when i debugged the code in AbstractEnvironment. Explicitly naming the bean profiles and activating them will resolve this issue but is not an option due to various reasons. |
Juergen Hoeller commented It seems you're assuming 'and' semantics there? It's actually defined as 'or' which is why the overall condition will match if only one of the elements matches, i.e. also if p1 is active and p2 is inactive - since "!p2" matches for the latter part. |
Juergen Hoeller commented BTW, we have an improvement request in the backlog asking for an 'and' concatenation option: #17063. That said, I'm afraid it's not planned for any concrete release at this point. |
Pushkar Prakash commented You,re right. Even a new release is not going to help us as we can't upgrade! I am thinking I should be able to hookup a bean at spring startup and set the system property to activate a (explicitly named) profile for each environment. |
Juergen Hoeller commented Indeed, you might be better off simplying the profile arrangement, pre-selecting a well-defined profile on startup. As for this JIRA issue, I'll mark it as "Works as Designed" then. |
Pushkar Prakash opened SPR-16465 and commented
bcd44f3
As mentioned in the above commit, the following works
But, this does not work
Even this does not work.
Affects: 3.2.18, 4.3.14, 5.0 GA
Reference URL: bcd44f3
Issue Links:
@Profile
annotationReferenced from: commits 285b01f, 1444094
The text was updated successfully, but these errors were encountered: