InitializableObject: thread safety concerns

7 views
Skip to first unread message

James Carter

unread,
Aug 9, 2024, 7:25:22 AM8/9/24
to Pac4j development mailing list
Hi,

I'm sure if the current implementation of InitializableObject is thread safe.


I believe that maxAttempts and minTimeIntervalBetweenAttemptsInMilliseconds should be declared volatile to guarantee visibility given their initialisation outside of a synchronized block and the public setters that are exposed.

I have raised a PR here if you concur with this observation. Thanks


James Carter

unread,
Aug 9, 2024, 7:25:22 AM8/9/24
to Pac4j development mailing list
Hi,

I'm not sure if the current implementation of InitializableObject is entirely thread safe. Given the publicly exposed setters and initial assignments outside of a synchronized block, I believe that maxAttempts and minTimeIntervalBetweenAttemptsInMilliseconds should be declared volatile to guarantee visibility to other threads.

If you concur with this view, I have raised a PR here: https://github.com/pac4j/pac4j/pull/2989

Thanks

Jérôme LELEU

unread,
Aug 9, 2024, 8:50:52 AM8/9/24
to James Carter, Pac4j development mailing list
Hi,

It makes sense.
Thanks.
Best regards,
Jérôme


--
You received this message because you are subscribed to the Google Groups "Pac4j development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pac4j-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pac4j-dev/438cc92f-b757-4363-8e70-84399c879ad9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages