Skip to content

Profiles should be comparable when created via Profiles.of() #25340

@stsypanov

Description

@stsypanov

Suppose we have this code in production:

private boolean isExternalProfileEnabled() {
  return environment.acceptsProfiles(Profiles.of("external"));
}

Then I want to mock this in tests and I write something like:

when(environment.acceptsProfiles(Profiles.of("external"))).thenReturn(true);

And at runtime the mock fails to return true, because comparison of arguments fails due to missing equals() and hashCode() implementations in ParsedProfiles.

This makes us use the deprecated API and rewrite the example code like:

private boolean isExternalProfileEnabled() {
  return environment.acceptsProfiles("external");
}

and use of the deprecated API in turn makes Sonar unhappy.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions