From 0eb391edbd6508eea720d493fd14bc031b2da8f3 Mon Sep 17 00:00:00 2001 From: Jaxsun McCarthy Huggan Date: Wed, 28 Nov 2018 11:40:31 -0800 Subject: do not post to submit record endpoint without authentication this endpoint appears to require authentication even on instances which allow anonymous connections. Change-Id: Ia4831aa2864391effb8ba3846e18bb299c44783e Signed-off-by: Jaxsun McCarthy Huggan --- .../mylyn/internal/gerrit/core/client/GerritClient29.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient29.java b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient29.java index 293e89981..b9908478d 100644 --- a/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient29.java +++ b/org.eclipse.mylyn.gerrit.core/src/org/eclipse/mylyn/internal/gerrit/core/client/GerritClient29.java @@ -27,6 +27,7 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.mylyn.commons.core.StatusHandler; +import org.eclipse.mylyn.commons.net.AuthenticationType; import org.eclipse.mylyn.internal.gerrit.core.GerritCorePlugin; import org.eclipse.mylyn.internal.gerrit.core.client.GerritHttpClient.ErrorHandler; import org.eclipse.mylyn.internal.gerrit.core.client.compat.ChangeDetailX; @@ -246,6 +247,9 @@ public class GerritClient29 extends GerritClient { private List currentSubmitRecord(String uri, IProgressMonitor monitor) throws GerritException { List submitRecordList = new ArrayList(); + if (getRepository().getCredentials(AuthenticationType.REPOSITORY) == null) { + return submitRecordList; + } SubmitRecord[] submitRecordArray = getRestClient().executePostRestRequest(uri, new SubmitRecord(), SubmitRecord[].class, new ErrorHandler() { @Override @@ -388,9 +392,8 @@ public class GerritClient29 extends GerritClient { List listCommitInfo = relatedChangesInfo.getCommitInfo(); boolean needed = true; for (RelatedChangeAndCommitInfo relatedChangeAndCommitInfo : listCommitInfo) { - if (relatedChangeAndCommitInfo.getCommitInfo() - .getCommit() - .equalsIgnoreCase(changeInfo28.getCurrentRevision())) { + if (relatedChangeAndCommitInfo.getCommitInfo().getCommit().equalsIgnoreCase( + changeInfo28.getCurrentRevision())) { needed = false; } else { if (relatedChangeAndCommitInfo.getChangeNumber() > 0) { -- cgit v1.2.3