Skip to content

InMemoryReactiveClientRegistrationRepository should not use ConcurrentReferenceHashMap #7299

Closed
@jzheaux

Description

@jzheaux

ConcurrentReferenceHashMap is a cache-style map that uses weak references.

Since InMemoryReactiveClientRegistrationRepository is intended to be persistent, it should instead use ConcurrentHashMap.

The change to be made is in the InMemoryReactiveClientRegistrationRepository constructor that instantiates a ConcurrentReferenceHashMap:

Assert.notEmpty(registrations, "registrations cannot be empty");
this.clientIdToClientRegistration = new ConcurrentReferenceHashMap<>(); // <-- this line
for (ClientRegistration registration : registrations) {
	Assert.notNull(registration, "registrations cannot contain null values");
	this.clientIdToClientRegistration.put(registration.getRegistrationId(), registration);
}

should instead be

Assert.notEmpty(registrations, "registrations cannot be empty");
this.clientIdToClientRegistration = new ConcurrentHashMap<>();  // <-- this line
for (ClientRegistration registration : registrations) {
	Assert.notNull(registration, "registrations cannot contain null values");
	this.clientIdToClientRegistration.put(registration.getRegistrationId(), registration);
}

This ticket should also be backported to 5.1.x.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions