Source:
public <T> T execute(Request<T> request, boolean authenticateIfNeeded, IProgressMonitor monitor) throws IOException, GerritException { String openIdProvider = getOpenIdProvider(); hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); for (int attempt = 0; attempt < 2; attempt++) { if (authenticateIfNeeded) { if (needsAuthentication()) { AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY); if (openIdProvider != null || credentials != null) { authenticate(openIdProvider, monitor); } } if (!obtainedXsrfKey) { updateXsrfKey(monitor); } } HttpMethodBase method = request.createMethod(); if (obtainedXsrfKey) { if (GerritVersion.isVersion2120OrLater(version)) { method.setRequestHeader(X_GERRIT_AUTHORITY, getXsrfKey()); } else { method.setRequestHeader(X_GERRIT_AUTHORITY, xsrfKey); } } try { execute(method, monitor); } catch (IOException e) { WebUtil.releaseConnection(method, monitor); throw e; } catch (RuntimeException e) { WebUtil.releaseConnection(method, monitor); throw e; } int code = method.getStatusCode(); if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_ACCEPTED || code == HttpURLConnection.HTTP_CREATED) { try { return request.process(method); } finally { WebUtil.releaseConnection(method, monitor); } } else if (code == HttpURLConnection.HTTP_NO_CONTENT) { try { return null; } finally { WebUtil.releaseConnection(method, monitor); } } else { try { request.handleError(method); } finally { WebUtil.releaseConnection(method, monitor); } if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) { authenticate(openIdProvider, monitor); this.obtainedXsrfKey = false; } else if (code == HttpURLConnection.HTTP_NOT_FOUND) { try { authenticate(openIdProvider, monitor); } catch (IOException e) { throw new GerritHttpException(code); } } } } throw new GerritLoginException(); }

Target:
public <T> T execute(Request<T> request, boolean authenticateIfNeeded, IProgressMonitor monitor) throws IOException, GerritException { String openIdProvider = getOpenIdProvider(); hostConfiguration = WebUtil.createHostConfiguration(httpClient, location, monitor); for (int attempt = 0; attempt < 2; attempt++) { if (authenticateIfNeeded) { if (needsAuthentication()) { AuthenticationCredentials credentials = location.getCredentials(AuthenticationType.REPOSITORY); if (openIdProvider != null || credentials != null) { authenticate(openIdProvider, monitor); } } if (!obtainedXsrfKey) { updateXsrfKey(monitor); } } HttpMethodBase method = request.createMethod(); if (obtainedXsrfKey) { if (GerritVersion.isVersion2120OrLater(version)) { method.setRequestHeader(X_GERRIT_AUTHORITY, getXsrfKey()); } else { method.setRequestHeader(X_GERRIT_AUTHORITY, xsrfKey); } } try { execute(method, monitor); } catch (IOException e) { WebUtil.releaseConnection(method, monitor); throw e; } catch (RuntimeException e) { WebUtil.releaseConnection(method, monitor); throw e; } int code = method.getStatusCode(); if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_ACCEPTED || code == HttpURLConnection.HTTP_CREATED) { try { return request.process(method); } finally { WebUtil.releaseConnection(method, monitor); } } else if (code == HttpURLConnection.HTTP_NO_CONTENT) { try { return null; } finally { WebUtil.releaseConnection(method, monitor); } } else { try { request.handleError(method); } finally { WebUtil.releaseConnection(method, monitor); } if (code == HttpURLConnection.HTTP_UNAUTHORIZED || code == HttpURLConnection.HTTP_FORBIDDEN) { authenticate(openIdProvider, monitor); this.obtainedXsrfKey = false; } else if (code == HttpURLConnection.HTTP_NOT_FOUND) { try { authenticate(openIdProvider, monitor); } catch (IOException e) { throw new GerritHttpException(code); } } else { throw new GerritHttpException(code); } } } throw new GerritLoginException(); }