Files
maven-mvnd/common
Tamas Cservenak 442ac9d4e5
Some checks failed
Early Access / Default build (without GraalVM) (push) Has been cancelled
Early Access / Build with GraalVM on macos-13 (push) Has been cancelled
Early Access / Build with GraalVM on macos-latest (push) Has been cancelled
Early Access / Build with GraalVM on ubuntu-latest (push) Has been cancelled
Early Access / Build with GraalVM on windows-latest (push) Has been cancelled
Make DaemonRegistry concurrency-safe (#1281) (#1427)
The previous implementation had two issues:

The memmory-mapped file was created in the constructor and ignored file expansions by other threads or processes. It would then overwrite the file with its own, smaller size buffer. Replaced the memory mapping with a regular InputStream/OutputStream approach. Memory mapping is not very useful in this scenario anyway, since the file is small and infrequently read and we always read/write the entire file.

The tryLock method was broken and only tried locking once. If the lock could not be acquired, it returned null and the subsequent code then ignored that fact and proceeded without locking. I've moved the retry loop and failure handling into the lock method, which gives it the intended behavior of waiting for a lock for 20s and then failing.

The test expectation for the "big registry" test has changed, since we no longer manually increase the file size to multiples of two, but instead simply write out exactly the bytes we need.

I droped the String size requirement, since DataInputStream handles arbitrarly long Strings. I also changed the exception handling to consistently do recovery on any kind of exception while reading/writing, since it is reasonable to assume that any such exception indicates a broken registry file. I've also adjusted the user-facing message to only tell them to delete the file if recovery fails.

---

Backport of bb1191e4c6
Co-authored-by: Stefan Oehme <st.oehme@gmail.com>
2025-09-12 13:05:30 +02:00
..
2024-08-20 23:52:07 +02:00