kevinrr888 commented on code in PR #6025:
URL: https://github.com/apache/accumulo/pull/6025#discussion_r2627759399
##########
core/src/main/java/org/apache/accumulo/core/fate/zookeeper/DistributedReadWriteLock.java:
##########
@@ -154,22 +155,27 @@ public void lockInterruptibly() throws
InterruptedException {
@Override
public boolean tryLock() {
- if (entry == -1) {
- entry = qlock.addEntry(new ParsedLock(this.lockType(),
this.userData).getLockData());
- log.info("Added lock entry {} userData {} lockType {}", entry,
- new String(this.userData, UTF_8), lockType());
- }
- SortedMap<Long,byte[]> entries = qlock.getEarlierEntries(entry);
+ var entryVal = entry.updateAndGet(val -> {
+ if (val == -1) {
+ var newVal = qlock.addEntry(new ParsedLock(this.lockType(),
this.userData).getLockData());
Review Comment:
Looking at this again, I agree with you that no changes are needed for this
class. When I was reviewing this the first time, I had incorrectly followed a
code trace. This class is not intended to be thread safe and threads never
share the same ReadLock. So, this can be safely marked not thread safe and I'll
revert my changes :+1:
--
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]