pilgr / Paper

Paper is a fast NoSQL-like storage for Java/Kotlin objects on Android with automatic schema migration support.
Apache License 2.0
2.34k stars 234 forks source link

Race condition in KeyLocker #170

Open Yrlec opened 4 years ago

Yrlec commented 4 years ago

Thank you for creating this great library!

I found a potential race condition on this line in KeyLocker: https://github.com/pilgr/Paper/blob/0e4e76ad7a9f30accbd6ba245166768cab39410d/paperdb/src/main/java/io/paperdb/KeyLocker.java#L29

One should use putIfAbsent instead. See https://stackoverflow.com/a/15850870/71354 for an explanation.

pilgr commented 4 years ago

@Yrlec Good catch, thanks!