Skip to content

SPEL PropertyOrFieldReference not threadsafe [SPR-5374] #10047

Closed
@spring-projects-issues

Description

@spring-projects-issues

Artur Biesiadowski opened SPR-5374 and commented

SPEL PropertyOrFieldReference makes Expressions unsafe to use from multiple threads. Cached accessor is replaced in the middle of method in case of mismatching resolution, possibly causing confusion for another thread.

I have attached a small test below which sometimes manages to reproduce the issue. Unfortunately, as it is race condition, it happens only sometimes - on my dual core machine, about 50% of times. Anyway, code review can spot the bug without the need for reproducing it.

In this case I have chosen degenerated example, where field is replaced with accessor method. Unfortunately, entire package seems to be quite thread unsafe - ReflectionPropertyReaderExecutor has non-final fields, which, due to lack of synchronization, can leak as nulls to different threads, possibly causing exceptions even on simples cases of accessing type of object.


Affects: 3.0 M1

Attachments:

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions