Skip to content

Objects with multi-threaded access should not lazily populate a hash field [SPR-11428] #16054

@spring-projects-issues

Description

@spring-projects-issues

Juergen Hoeller opened SPR-11428 and commented

MethodParameter, RequestMappingInfo and SimpMessageMappingInfo currently cache a lazily calculated hash value in a regular int field. This should be avoided since instances of those classes can be used as keys in caches with multi-threaded access, exposing an incomplete visibility risk for non-volatile fields.

Instead of going with volatile or synchronized, let's rather not cache those hash values to begin with but rather design simple, cheap enough hashCode() implementations that always calculate on the fly.


Affects: 3.2.7, 4.0.1

Backported to: 3.2.8

Metadata

Metadata

Assignees

Labels

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