Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move setting of initPending to false only after initializing the jdk log manager, fix #646 #647

Merged
merged 2 commits into from
Feb 12, 2021

Conversation

syjer
Copy link
Contributor

@syjer syjer commented Feb 8, 2021

Seems to fix the issue as generated by the test case. Not 100% sure it cover all cases.

Fix issue #646 .

To be noted, we may need to cleanup the init part of the logging...

@syjer syjer changed the title #646 move setting of initPending to false only after initializing the jdk log manager move setting of initPending to false only after initializing the jdk log manager, fix #646 Feb 8, 2021
Without volatile we can have the situation where thread 2 sees the value of initPending to be false and thus doesn't go through the synced section but sees loggers as not yet visible.

This was rare and the test only failed on the first run on my machine before always passing.

Hopefully, it should always work now. Fingers crossed.

NOTE: Both of the changed classes use a version of the "double checked locking" pattern which the internet says requires volatile.
@danfickle
Copy link
Owner

Thanks @syjer,

I've added a commit with the use of volatile. I still can't guarantee it is correct as the test only failed the very first time I started my computer.

@syjer
Copy link
Contributor Author

syjer commented Feb 11, 2021

you are absolutely right about the volatile! Surprising that the test on my pc was not catching this case (maybe increasing the number of concurrent thread?).

@danfickle danfickle merged commit 67913a4 into danfickle:open-dev-v1 Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants