@VisibleForTesting
  static boolean isBrokenPipe(IOException original) {
    Throwable exception = original;
    while (exception != null) {
      String message = exception.getMessage();
      if (message != null && message.toLowerCase(Locale.US).contains("broken pipe")) {
        return true;
      }

      exception = exception.getCause();
      if (exception == original) { // just in case if there's a circular chain
        return false;
      }
    }
    return false;
  }
@Test
  public void testIsBrokenPipe_terminatesWhenCauseIsOriginal() {
    IOException exception = Mockito.mock(IOException.class);
    Mockito.when(exception.getCause()).thenReturn(exception);

    Assert.assertFalse(RegistryEndpointCaller.isBrokenPipe(exception));
  }