in hbase-oss/src/main/java/org/apache/hadoop/hbase/oss/sync/TreeLockManager.java [438:463]
public AutoLock lockListings(Path[] rawPaths, Depth depth) throws IOException {
Path[] paths = norm(rawPaths);
for (int i = 0; i < paths.length; i++) {
LOG.debug("About to lock for listings: {}", paths[i]);
treeWriteLock(paths[i], depth);
}
return new AutoLock() {
public void close() throws IOException {
Throwable lastThrown = null;
for (int i = 0; i < paths.length; i++) {
LOG.debug("About to unlock after listings: {}", paths[i]);
try {
writeUnlock(paths[i]);
} catch (Throwable e) {
lastThrown = e;
LOG.warn("Caught throwable while unlocking: {}", e.getMessage());
e.printStackTrace();
}
}
if (lastThrown != null) {
throw new IOException("At least one throwable caught while unlocking",
lastThrown);
}
}
};
}