public static String tryToGetClientIp(HttpServletRequest request) {
    String forwardedFor = request.getHeader("X-FORWARDED-FOR");
    if (!Strings.isNullOrEmpty(forwardedFor)) {
      return X_FORWARDED_FOR_SPLITTER.splitToList(forwardedFor).get(0);
    }
    return request.getRemoteAddr();
  }
@Test
  public void testTryToGetClientIp() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("X-FORWARDED-FOR", "172.1.1.1,172.1.1.2");
    request.setRemoteAddr("172.1.1.3");
    String ip = WebUtils.tryToGetClientIp(request);
    assertThat(ip).isEqualTo("172.1.1.1");

    request.removeHeader("X-FORWARDED-FOR");
    ip = WebUtils.tryToGetClientIp(request);
    assertThat(ip).isEqualTo("172.1.1.3");
  }