rishabhdaim commented on code in PR #2660:
URL: https://github.com/apache/jackrabbit-oak/pull/2660#discussion_r2693519797
##########
oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/IndexCopier.java:
##########
@@ -363,28 +366,31 @@ public boolean isCopyInProgress(LocalIndexFile file) {
* @param timeoutMillis
*/
public void waitForCopyCompletion(LocalIndexFile file, long timeoutMillis)
{
- final Monitor.Guard notCopyingGuard = new
Monitor.Guard(copyCompletionMonitor) {
- @Override
- public boolean isSatisfied() {
- return !isCopyInProgress(file);
- }
- };
long localLength = file.actualSize();
long lastLocalLength = localLength;
boolean notCopying = !isCopyInProgress(file);
while (!notCopying) {
+ final long deadline = System.nanoTime() +
TimeUnit.MILLISECONDS.toNanos(timeoutMillis);
+ copyCompletionLock.lock();
Review Comment:
`copyCompletionLock.lock()` is required to wait for the condition i.e.
`isCopyInProgress(file)` in this case. I am not sure why do we need
`copyCompletionLock.tryLock(long, TimeUnit)` here.
Also, `nanos` is used to for better time management and it was suggested by
`cursor` and other `AI` tools over timeout in millis.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]