Source:
<code>public void run() { if (slot == null) { return; } LOG.trace("{}: about to release {}", ShortCircuitCache.this, slot); final DfsClientShm shm = (DfsClientShm)slot.getShm(); final DomainSocket shmSock = shm.getPeer().getDomainSocket(); final String path = shmSock.getPath(); DataOutputStream out = null; boolean success = false; int retries = 2; try { <START> while (retries > 0) { <END> try { if (domainSocket == null || !domainSocket.isOpen()) { domainSocket = DomainSocket.connect(path); } out = new DataOutputStream( new BufferedOutputStream(domainSocket.getOutputStream())); new Sender(out).releaseShortCircuitFds(slot.getSlotId()); DataInputStream in = new DataInputStream(domainSocket.getInputStream()); ReleaseShortCircuitAccessResponseProto resp = ReleaseShortCircuitAccessResponseProto .parseFrom(PBHelperClient.vintPrefixed(in)); if (resp.getStatus() != Status.SUCCESS) { String error = resp.hasError() ? resp.getError() : "(unknown)"; throw new IOException(resp.getStatus().toString() + ": " + error); } LOG.trace("{}: released {}", this, slot); success = true; break; } catch (SocketException se) { retries--; domainSocket.close(); domainSocket = null; } } } catch (IOException e) { LOG.warn(ShortCircuitCache.this + ": failed to release " + "short-circuit shared memory slot " + slot + " by sending " + "ReleaseShortCircuitAccessRequestProto to " + path + ". Closing shared memory segment. " + "DataNode may have been stopped or restarted", e); } finally { if (success) { shmManager.freeSlot(slot); } else { shm.getEndpointShmManager().shutdown(shm); IOUtilsClient.cleanupWithLogger(LOG, domainSocket, out); domainSocket = null; } } }</code><technical_language>If retries 0, code silently ignore error. handle this case better</technical_language>

Target:
public void run() { if (slot == null) { return; } LOG.trace("{}: about to release {}", ShortCircuitCache.this, slot); final DfsClientShm shm = (DfsClientShm)slot.getShm(); final DomainSocket shmSock = shm.getPeer().getDomainSocket(); final String path = shmSock.getPath(); DataOutputStream out = null; boolean success = false; int retries = 2; try { while (retries > 0) { try { if (domainSocket == null || !domainSocket.isOpen()) { domainSocket = DomainSocket.connect(path); } out = new DataOutputStream( new BufferedOutputStream(domainSocket.getOutputStream())); new Sender(out).releaseShortCircuitFds(slot.getSlotId()); DataInputStream in = new DataInputStream(domainSocket.getInputStream()); ReleaseShortCircuitAccessResponseProto resp = ReleaseShortCircuitAccessResponseProto .parseFrom(PBHelperClient.vintPrefixed(in)); if (resp.getStatus() != Status.SUCCESS) { String error = resp.hasError() ? resp.getError() : "(unknown)"; throw new IOException(resp.getStatus().toString() + ": " + error); } LOG.trace("{}: released {}", this, slot); success = true; break; } catch (SocketException se) { retries--; domainSocket.close(); domainSocket = null; if (retries == 0) { throw new SocketException("Create domain socket failed"); } } } } catch (IOException e) { LOG.warn(ShortCircuitCache.this + ": failed to release " + "short-circuit shared memory slot " + slot + " by sending " + "ReleaseShortCircuitAccessRequestProto to " + path + ". Closing shared memory segment. " + "DataNode may have been stopped or restarted", e); } finally { if (success) { shmManager.freeSlot(slot); } else { shm.getEndpointShmManager().shutdown(shm); IOUtilsClient.cleanupWithLogger(LOG, domainSocket, out); domainSocket = null; } } }