Skip to content

Conversation

@rishabhdaim
Copy link
Contributor

No description provided.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

// timeout
break;
}
notCopyingCondition.awaitNanos(remaining);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole nano calculation seems clumsy. Why not just notCopyingCondition.await(timeoutMillis, TimeUnit.MILLISECONDS) ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the thread could be woken up in some cases, and so a loop is needed, and so a calculation is needed.

boolean notCopying = !isCopyInProgress(file);
while (!notCopying) {
final long deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(timeoutMillis);
copyCompletionLock.lock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is that working with the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by following this logic, we ensure that we block for only an absolute time in future.

On each inner-loop iteration you recompute remaining = deadline - System.nanoTime()

This is to ensure that regardless of how many times the threads are woken, we only wait for timeoutMillis.

@mbaedke mbaedke self-requested a review January 6, 2026 11:38
Copy link
Contributor

@mbaedke mbaedke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments inline.

@rishabhdaim rishabhdaim requested a review from mbaedke January 7, 2026 07:35
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.

3 participants