ctubbsii commented on code in PR #3813: URL: https://github.com/apache/accumulo/pull/3813#discussion_r1346876481
########## core/src/main/java/org/apache/accumulo/core/util/compaction/ExternalCompactionUtil.java: ########## @@ -98,17 +98,12 @@ public static String getHostPortString(HostAndPort address) { */ public static Optional<HostAndPort> findCompactionCoordinator(ClientContext context) { final String lockPath = context.getZooKeeperRoot() + Constants.ZCOORDINATOR_LOCK; - try { - var zk = ZooSession.getAnonymousSession(context.getZooKeepers(), - context.getZooKeepersSessionTimeOut()); - byte[] address = ServiceLock.getLockData(zk, ServiceLock.path(lockPath)); - if (null == address) { - return Optional.empty(); - } - return Optional.of(HostAndPort.fromString(new String(address))); - } catch (KeeperException | InterruptedException e) { - throw new RuntimeException(e); + byte[] address = + ServiceLock.getLockData(context.getZooCache(), ServiceLock.path(lockPath), new ZcStat()); + if (null == address) { + return Optional.empty(); } + return Optional.of(HostAndPort.fromString(new String(address))); Review Comment: There's a couple of different variants of this that are slightly more concise, some could inline the lockPath as well. I couldn't get it more concise than 3 lines. But, there is a variant of this that would inline the lockPath and still be only 3 lines total. I'm not sure if you want to go with any of them. But, at a minimum, the String should be interpreting the address as UTF-8, because that's how it should have been persisted. ```suggestion Optional<byte[]> address = Optional.ofNullable( ServiceLock.getLockData(context.getZooCache(), ServiceLock.path(lockPath), new ZcStat())); return address.map(bytes -> new String(bytes, UTF_8)).map(HostAndPort::fromString); ``` -- 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: notifications-unsubscr...@accumulo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org