Migrate restapi classes to Flogger
This is the next part of the migration to Flogger. This change migrates all classes of the 'restapi' module to Flogger. Classes of the 'httpd' and 'server' modules have been migrated by predecessor changes. Other modules continue to use slf4j. They should be migrated by follow-up changes. During this migration we try to make the log statements more consistent: - avoid string concatenation - avoid usage of String.format(...) Change-Id: I11ef03118e5c104bd2e11cb0ad9d37e09514355f Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -29,9 +29,9 @@ java_library(
|
||||
"//lib/commons:codec",
|
||||
"//lib/commons:compress",
|
||||
"//lib/commons:lang",
|
||||
"//lib/flogger:api",
|
||||
"//lib/guice",
|
||||
"//lib/guice:guice-assistedinject",
|
||||
"//lib/jgit/org.eclipse.jgit:jgit",
|
||||
"//lib/log:api",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.account;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.common.errors.InvalidSshKeyException;
|
||||
@@ -43,12 +44,10 @@ import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class AddSshKey implements RestModifyView<AccountResource, SshKeyInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(AddSshKey.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final PermissionBackend permissionBackend;
|
||||
@@ -104,8 +103,10 @@ public class AddSshKey implements RestModifyView<AccountResource, SshKeyInput> {
|
||||
try {
|
||||
addKeyFactory.create(user, sshKey).send();
|
||||
} catch (EmailException e) {
|
||||
log.error(
|
||||
"Cannot send SSH key added message to " + user.getAccount().getPreferredEmail(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Cannot send SSH key added message to %s", user.getAccount().getPreferredEmail());
|
||||
}
|
||||
|
||||
user.getUserName().ifPresent(sshKeyCache::evict);
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.account;
|
||||
|
||||
import static com.google.gerrit.extensions.client.AuthType.DEVELOPMENT_BECOME_ANY_ACCOUNT;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.extensions.api.accounts.EmailInput;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
@@ -45,11 +46,9 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CreateEmail implements RestModifyView<AccountResource, EmailInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateEmail.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
CreateEmail create(String email);
|
||||
@@ -126,7 +125,7 @@ public class CreateEmail implements RestModifyView<AccountResource, EmailInput>
|
||||
info.email = email;
|
||||
if (input.noConfirmation || isDevMode) {
|
||||
if (isDevMode) {
|
||||
log.warn("skipping email validation in developer mode");
|
||||
logger.atWarning().log("skipping email validation in developer mode");
|
||||
}
|
||||
try {
|
||||
accountManager.link(user.getAccountId(), AuthRequest.forEmail(email));
|
||||
@@ -146,7 +145,7 @@ public class CreateEmail implements RestModifyView<AccountResource, EmailInput>
|
||||
sender.send();
|
||||
info.pendingConfirmation = true;
|
||||
} catch (EmailException | RuntimeException e) {
|
||||
log.error("Cannot send email verification message to " + email, e);
|
||||
logger.atSevere().withCause(e).log("Cannot send email verification message to %s", email);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.account;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.ContributorAgreement;
|
||||
import com.google.gerrit.common.data.PermissionRule;
|
||||
import com.google.gerrit.common.data.PermissionRule.Action;
|
||||
@@ -36,12 +37,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class GetAgreements implements RestReadView<AccountResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(GetAgreements.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final ProjectCache projectCache;
|
||||
@@ -85,13 +84,11 @@ public class GetAgreements implements RestReadView<AccountResource> {
|
||||
if (rule.getGroup().getUUID() != null) {
|
||||
groupIds.add(rule.getGroup().getUUID());
|
||||
} else {
|
||||
log.warn(
|
||||
"group \""
|
||||
+ rule.getGroup().getName()
|
||||
+ "\" does not "
|
||||
+ "exist, referenced in CLA \""
|
||||
+ ca.getName()
|
||||
+ "\"");
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"group \"%s\" does not exist, referenced in CLA \"%s\"",
|
||||
rule.getGroup().getName(), ca.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.account;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.auth.oauth.OAuthToken;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
@@ -27,14 +28,12 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
class GetOAuthToken implements RestReadView<AccountResource> {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final String BEARER_TYPE = "bearer";
|
||||
private static final Logger log = LoggerFactory.getLogger(GetOAuthToken.class);
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final OAuthTokenCache tokenCache;
|
||||
@@ -72,14 +71,16 @@ class GetOAuthToken implements RestReadView<AccountResource> {
|
||||
|
||||
private static String getHostName(String canonicalWebUrl) {
|
||||
if (canonicalWebUrl == null) {
|
||||
log.error("No canonicalWebUrl defined in gerrit.config, OAuth may not work properly");
|
||||
logger
|
||||
.atSevere()
|
||||
.log("No canonicalWebUrl defined in gerrit.config, OAuth may not work properly");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return new URI(canonicalWebUrl).getHost();
|
||||
} catch (URISyntaxException e) {
|
||||
log.error("Invalid canonicalWebUrl '" + canonicalWebUrl + "'", e);
|
||||
logger.atSevere().withCause(e).log("Invalid canonicalWebUrl '%s'", canonicalWebUrl);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.account;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
@@ -44,12 +45,10 @@ import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class PutPreferred implements RestModifyView<AccountResource.Email, Input> {
|
||||
private static final Logger log = LoggerFactory.getLogger(PutPreferred.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final PermissionBackend permissionBackend;
|
||||
@@ -117,15 +116,17 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
|
||||
externalIds.byEmail(preferredEmail);
|
||||
if (!existingExtIdsWithThisEmail.isEmpty()) {
|
||||
// but the email is already assigned to another account
|
||||
log.warn(
|
||||
"Cannot set preferred email {} for account {} because it is owned"
|
||||
+ " by the following account(s): {}",
|
||||
preferredEmail,
|
||||
user.getAccountId(),
|
||||
existingExtIdsWithThisEmail
|
||||
.stream()
|
||||
.map(ExternalId::accountId)
|
||||
.collect(toList()));
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"Cannot set preferred email %s for account %s because it is owned"
|
||||
+ " by the following account(s): %s",
|
||||
preferredEmail,
|
||||
user.getAccountId(),
|
||||
existingExtIdsWithThisEmail
|
||||
.stream()
|
||||
.map(ExternalId::accountId)
|
||||
.collect(toList()));
|
||||
exception.set(
|
||||
Optional.of(
|
||||
new ResourceConflictException("email in use by another account")));
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.account;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.AcceptsCreate;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -45,14 +46,12 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class StarredChanges
|
||||
implements ChildCollection<AccountResource, AccountResource.StarredChange>,
|
||||
AcceptsCreate<AccountResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(StarredChanges.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final ChangesCollection changes;
|
||||
private final DynamicMap<RestView<AccountResource.StarredChange>> views;
|
||||
@@ -110,7 +109,7 @@ public class StarredChanges
|
||||
} catch (ResourceNotFoundException e) {
|
||||
throw new UnprocessableEntityException(String.format("change %s not found", id.get()));
|
||||
} catch (OrmException | PermissionBackendException | IOException e) {
|
||||
log.error("cannot resolve change", e);
|
||||
logger.atSevere().withCause(e).log("cannot resolve change");
|
||||
throw new UnprocessableEntityException("internal server error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.api.changes.AbandonInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
@@ -46,13 +47,11 @@ import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Abandon extends RetryingRestModifyView<ChangeResource, AbandonInput, ChangeInfo>
|
||||
implements UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Abandon.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final ChangeJson.Factory json;
|
||||
@@ -160,10 +159,10 @@ public class Abandon extends RetryingRestModifyView<ChangeResource, AbandonInput
|
||||
return description;
|
||||
}
|
||||
} catch (OrmException | IOException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId()),
|
||||
e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.gerrit.extensions.conditions.BooleanCondition.and;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -46,14 +47,13 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class CherryPick
|
||||
extends RetryingRestModifyView<RevisionResource, CherryPickInput, ChangeInfo>
|
||||
implements UiAction<RevisionResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CherryPick.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final PermissionBackend permissionBackend;
|
||||
private final CherryPickChange cherryPickChange;
|
||||
private final ChangeJson.Factory json;
|
||||
@@ -120,7 +120,10 @@ public class CherryPick
|
||||
try {
|
||||
projectStatePermitsWrite = projectCache.checkedGet(rsrc.getProject()).statePermitsWrite();
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to check if project state permits write: " + rsrc.getProject(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if project state permits write: %s", rsrc.getProject());
|
||||
}
|
||||
return new UiAction.Description()
|
||||
.setLabel("Cherry Pick")
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -30,11 +31,9 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.util.Collections;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DeleteReviewerByEmailOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(DeleteReviewerByEmailOp.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
DeleteReviewerByEmailOp create(Address reviewer, DeleteReviewerInput input);
|
||||
@@ -100,7 +99,7 @@ public class DeleteReviewerByEmailOp implements BatchUpdateOp {
|
||||
cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
|
||||
cm.send();
|
||||
} catch (Exception err) {
|
||||
log.error("Cannot email update for change " + change.getId(), err);
|
||||
logger.atSevere().withCause(err).log("Cannot email update for change %s", change.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
|
||||
@@ -57,11 +58,9 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DeleteReviewerOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(DeleteReviewerOp.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
DeleteReviewerOp create(AccountState reviewerAccount, DeleteReviewerInput input);
|
||||
@@ -248,7 +247,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
||||
cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
|
||||
cm.send();
|
||||
} catch (Exception err) {
|
||||
log.error("Cannot email update for change " + change.getId(), err);
|
||||
logger.atSevere().withCause(err).log("Cannot email update for change %s", change.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteVoteInput;
|
||||
@@ -64,12 +65,10 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteInput, Response<?>> {
|
||||
private static final Logger log = LoggerFactory.getLogger(DeleteVote.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ApprovalsUtil approvalsUtil;
|
||||
@@ -252,7 +251,7 @@ public class DeleteVote extends RetryingRestModifyView<VoteResource, DeleteVoteI
|
||||
cm.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
|
||||
cm.send();
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot email update for change " + change.getId(), e);
|
||||
logger.atSevere().withCause(e).log("Cannot email update for change %s", change.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.hash.Hasher;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gerrit.extensions.common.FileInfo;
|
||||
@@ -70,8 +71,6 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Files implements ChildCollection<RevisionResource, FileResource> {
|
||||
@@ -100,7 +99,7 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
|
||||
}
|
||||
|
||||
public static final class ListFiles implements ETagView<RevisionResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(ListFiles.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Option(name = "--base", metaVar = "revision-id")
|
||||
String base;
|
||||
@@ -248,9 +247,9 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
|
||||
try {
|
||||
return copy(res.files(), res.patchSetId(), resource, userId);
|
||||
} catch (PatchListObjectTooLargeException e) {
|
||||
log.warn("Cannot copy patch review flags: " + e.getMessage());
|
||||
logger.atWarning().log("Cannot copy patch review flags: %s", e.getMessage());
|
||||
} catch (IOException | PatchListNotAvailableException e) {
|
||||
log.warn("Cannot copy patch review flags", e);
|
||||
logger.atWarning().withCause(e).log("Cannot copy patch review flags");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -28,12 +29,10 @@ import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Ignore implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Ignore.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final StarredChangesUtil stars;
|
||||
|
||||
@@ -75,7 +74,7 @@ public class Ignore implements RestModifyView<ChangeResource, Input>, UiAction<C
|
||||
try {
|
||||
return stars.isIgnored(rsrc);
|
||||
} catch (OrmException e) {
|
||||
log.error("failed to check ignored star", e);
|
||||
logger.atSevere().withCause(e).log("failed to check ignored star");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -28,13 +29,11 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class MarkAsReviewed
|
||||
implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MarkAsReviewed.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
@@ -71,7 +70,7 @@ public class MarkAsReviewed
|
||||
.create(dbProvider.get(), rsrc.getNotes())
|
||||
.isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||
} catch (OrmException e) {
|
||||
log.error("failed to check if change is reviewed", e);
|
||||
logger.atSevere().withCause(e).log("failed to check if change is reviewed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
@@ -27,13 +28,11 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class MarkAsUnreviewed
|
||||
implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(MarkAsUnreviewed.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
@@ -70,7 +69,7 @@ public class MarkAsUnreviewed
|
||||
.create(dbProvider.get(), rsrc.getNotes())
|
||||
.isReviewedBy(rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||
} catch (OrmException e) {
|
||||
log.error("failed to check if change is reviewed", e);
|
||||
logger.atSevere().withCause(e).log("failed to check if change is reviewed");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.extensions.common.MergeableInfo;
|
||||
@@ -51,11 +52,9 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class Mergeable implements RestReadView<RevisionResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Mergeable.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Option(
|
||||
name = "--other-branches",
|
||||
@@ -176,7 +175,7 @@ public class Mergeable implements RestReadView<RevisionResource> {
|
||||
try {
|
||||
return ObjectId.fromString(ps.getRevision().get());
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error("Invalid revision on patch set " + ps);
|
||||
logger.atSevere().log("Invalid revision on patch set %s", ps);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.google.gerrit.server.permissions.RefPermission.CREATE_CHANGE;
|
||||
import static com.google.gerrit.server.query.change.ChangeData.asChanges;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.extensions.api.changes.MoveInput;
|
||||
@@ -70,13 +71,11 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, ChangeInfo>
|
||||
implements UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Move.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final PermissionBackend permissionBackend;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
@@ -298,7 +297,10 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
|
||||
return description;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to check if project state permits write: " + rsrc.getProject(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if project state permits write: %s", rsrc.getProject());
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -307,10 +309,10 @@ public class Move extends RetryingRestModifyView<ChangeResource, MoveInput, Chan
|
||||
return description;
|
||||
}
|
||||
} catch (OrmException | IOException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId()),
|
||||
e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
@@ -58,11 +59,9 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class PostReviewersOp implements BatchUpdateOp {
|
||||
private static final Logger log = LoggerFactory.getLogger(PostReviewersOp.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
PostReviewersOp create(
|
||||
@@ -262,7 +261,10 @@ public class PostReviewersOp implements BatchUpdateOp {
|
||||
cm.addExtraCCByEmail(copiedByEmail);
|
||||
cm.send();
|
||||
} catch (Exception err) {
|
||||
log.error("Cannot send email to new reviewers of change " + change.getId(), err);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(err)
|
||||
.log("Cannot send email to new reviewers of change %s", change.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.change;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -37,11 +38,9 @@ import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class QueryChanges implements RestReadView<TopLevelResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(QueryChanges.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final ChangeJson.Factory json;
|
||||
private final ChangeQueryBuilder qb;
|
||||
@@ -115,7 +114,7 @@ public class QueryChanges implements RestReadView<TopLevelResource> {
|
||||
} catch (QueryRequiresAuthException e) {
|
||||
throw new AuthException("Must be signed-in to use this operator");
|
||||
} catch (QueryParseException e) {
|
||||
log.debug("Reject change query with 400 Bad Request: " + queries, e);
|
||||
logger.atFine().withCause(e).log("Reject change query with 400 Bad Request: %s", queries);
|
||||
throw new BadRequestException(e.getMessage(), e);
|
||||
}
|
||||
return out.size() == 1 ? out.get(0) : out;
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.api.changes.RebaseInput;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
@@ -60,13 +61,12 @@ import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput, ChangeInfo>
|
||||
implements RestModifyView<RevisionResource, RebaseInput>, UiAction<RevisionResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Rebase.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final ImmutableSet<ListChangesOption> OPTIONS =
|
||||
Sets.immutableEnumSet(ListChangesOption.CURRENT_REVISION, ListChangesOption.CURRENT_COMMIT);
|
||||
|
||||
@@ -222,7 +222,10 @@ public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput
|
||||
return description;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to check if project state permits write: " + rsrc.getProject(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if project state permits write: %s", rsrc.getProject());
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -231,10 +234,10 @@ public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput
|
||||
return description;
|
||||
}
|
||||
} catch (OrmException | IOException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId()),
|
||||
e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -245,7 +248,10 @@ public class Rebase extends RetryingRestModifyView<RevisionResource, RebaseInput
|
||||
enabled = rebaseUtil.canRebase(rsrc.getPatchSet(), change.getDest(), repo, rw);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to check if patch set can be rebased: " + rsrc.getPatchSet(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if patch set can be rebased: %s", rsrc.getPatchSet());
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.api.changes.RestoreInput;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -50,13 +51,11 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Restore extends RetryingRestModifyView<ChangeResource, RestoreInput, ChangeInfo>
|
||||
implements UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Restore.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final RestoredSender.Factory restoredSenderFactory;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
@@ -153,7 +152,7 @@ public class Restore extends RetryingRestModifyView<ChangeResource, RestoreInput
|
||||
cm.setChangeMessage(message.getMessage(), ctx.getWhen());
|
||||
cm.send();
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot email update for change " + change.getId(), e);
|
||||
logger.atSevere().withCause(e).log("Cannot email update for change %s", change.getId());
|
||||
}
|
||||
changeRestored.fire(
|
||||
change, patchSet, ctx.getAccount(), Strings.emptyToNull(input.message), ctx.getWhen());
|
||||
@@ -178,7 +177,10 @@ public class Restore extends RetryingRestModifyView<ChangeResource, RestoreInput
|
||||
return description;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to check if project state permits write: " + rsrc.getProject(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if project state permits write: %s", rsrc.getProject());
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -187,10 +189,10 @@ public class Restore extends RetryingRestModifyView<ChangeResource, RestoreInput
|
||||
return description;
|
||||
}
|
||||
} catch (OrmException | IOException e) {
|
||||
log.error(
|
||||
String.format(
|
||||
"Failed to check if the current patch set of change %s is locked", change.getId()),
|
||||
e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if the current patch set of change %s is locked", change.getId());
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.gerrit.server.permissions.RefPermission.CREATE_CHANGE;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
@@ -85,13 +86,11 @@ import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.util.ChangeIdUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Revert extends RetryingRestModifyView<ChangeResource, RevertInput, ChangeInfo>
|
||||
implements UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Revert.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<ReviewDb> db;
|
||||
private final PermissionBackend permissionBackend;
|
||||
@@ -265,7 +264,10 @@ public class Revert extends RetryingRestModifyView<ChangeResource, RevertInput,
|
||||
try {
|
||||
projectStatePermitsWrite = projectCache.checkedGet(rsrc.getProject()).statePermitsWrite();
|
||||
} catch (IOException e) {
|
||||
log.error("Failed to check if project state permits write: " + rsrc.getProject(), e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Failed to check if project state permits write: %s", rsrc.getProject());
|
||||
}
|
||||
return new UiAction.Description()
|
||||
.setLabel("Revert")
|
||||
@@ -306,7 +308,10 @@ public class Revert extends RetryingRestModifyView<ChangeResource, RevertInput,
|
||||
cm.setAccountsToNotify(accountsToNotify);
|
||||
cm.send();
|
||||
} catch (Exception err) {
|
||||
log.error("Cannot send email for revert change " + change.getId(), err);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(err)
|
||||
.log("Cannot send email for revert change %s", change.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
@@ -61,11 +62,10 @@ import java.util.stream.Stream;
|
||||
import org.apache.commons.lang.mutable.MutableDouble;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ReviewerRecommender {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReviewerRecommender.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final double BASE_REVIEWER_WEIGHT = 10;
|
||||
private static final double BASE_OWNER_WEIGHT = 1;
|
||||
private static final double BASE_COMMENT_WEIGHT = 0.5;
|
||||
@@ -140,11 +140,11 @@ public class ReviewerRecommender {
|
||||
if (Strings.isNullOrEmpty(pluginWeight)) {
|
||||
pluginWeight = "1";
|
||||
}
|
||||
log.debug("weight for {}: {}", key, pluginWeight);
|
||||
logger.atFine().log("weight for %s: %s", key, pluginWeight);
|
||||
try {
|
||||
weights.add(Double.parseDouble(pluginWeight));
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("Exception while parsing weight for {}", key, e);
|
||||
logger.atSevere().withCause(e).log("Exception while parsing weight for %s", key);
|
||||
weights.add(1d);
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class ReviewerRecommender {
|
||||
}
|
||||
}
|
||||
} catch (ExecutionException | InterruptedException e) {
|
||||
log.error("Exception while suggesting reviewers", e);
|
||||
logger.atSevere().withCause(e).log("Exception while suggesting reviewers");
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ public class ReviewerRecommender {
|
||||
return suggestions;
|
||||
} catch (QueryParseException e) {
|
||||
// Unhandled, because owner:self will never provoke a QueryParseException
|
||||
log.error("Exception while suggesting reviewers", e);
|
||||
logger.atSevere().withCause(e).log("Exception while suggesting reviewers");
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public class ReviewerRecommender {
|
||||
} catch (QueryParseException e) {
|
||||
// Unhandled: If an exception is thrown, we won't increase the
|
||||
// candidates's score
|
||||
log.error("Exception while suggesting reviewers", e);
|
||||
logger.atSevere().withCause(e).log("Exception while suggesting reviewers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.extensions.common.GroupBaseInfo;
|
||||
@@ -66,10 +67,10 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ReviewersUtil {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
@Singleton
|
||||
private static class Metrics {
|
||||
final Timer0 queryAccountsLatency;
|
||||
@@ -113,8 +114,6 @@ public class ReviewersUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ReviewersUtil.class);
|
||||
|
||||
// Generate a candidate list at 2x the size of what the user wants to see to
|
||||
// give the ranking algorithm a good set of candidates it can work with
|
||||
private static final int CANDIDATE_LIST_MULTIPLIER = 2;
|
||||
@@ -170,35 +169,37 @@ public class ReviewersUtil {
|
||||
throws IOException, OrmException, ConfigInvalidException, PermissionBackendException {
|
||||
CurrentUser currentUser = self.get();
|
||||
if (changeNotes != null) {
|
||||
log.debug(
|
||||
"Suggesting reviewers for change {} to user {}.",
|
||||
changeNotes.getChangeId().get(),
|
||||
currentUser.getLoggableName());
|
||||
logger
|
||||
.atFine()
|
||||
.log(
|
||||
"Suggesting reviewers for change %s to user %s.",
|
||||
changeNotes.getChangeId().get(), currentUser.getLoggableName());
|
||||
} else {
|
||||
log.debug(
|
||||
"Suggesting default reviewers for project {} to user {}.",
|
||||
projectState.getName(),
|
||||
currentUser.getLoggableName());
|
||||
logger
|
||||
.atFine()
|
||||
.log(
|
||||
"Suggesting default reviewers for project %s to user %s.",
|
||||
projectState.getName(), currentUser.getLoggableName());
|
||||
}
|
||||
|
||||
String query = suggestReviewers.getQuery();
|
||||
log.debug("Query: {}", query);
|
||||
logger.atFine().log("Query: %s", query);
|
||||
int limit = suggestReviewers.getLimit();
|
||||
|
||||
if (!suggestReviewers.getSuggestAccounts()) {
|
||||
log.debug("Reviewer suggestion is disabled.");
|
||||
logger.atFine().log("Reviewer suggestion is disabled.");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<Account.Id> candidateList = new ArrayList<>();
|
||||
if (!Strings.isNullOrEmpty(query)) {
|
||||
candidateList = suggestAccounts(suggestReviewers);
|
||||
log.debug("Candidate list: {}", candidateList);
|
||||
logger.atFine().log("Candidate list: %s", candidateList);
|
||||
}
|
||||
|
||||
List<Account.Id> sortedRecommendations =
|
||||
recommendAccounts(changeNotes, suggestReviewers, projectState, candidateList);
|
||||
log.debug("Sorted recommendations: {}", sortedRecommendations);
|
||||
logger.atFine().log("Sorted recommendations: %s", sortedRecommendations);
|
||||
|
||||
// Filter accounts by visibility and enforce limit
|
||||
List<Account.Id> filteredRecommendations = new ArrayList<>();
|
||||
@@ -214,7 +215,7 @@ public class ReviewersUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
log.debug("Filtered recommendations: {}", filteredRecommendations);
|
||||
logger.atFine().log("Filtered recommendations: %s", filteredRecommendations);
|
||||
|
||||
List<SuggestedReviewerInfo> suggestedReviewers = loadAccounts(filteredRecommendations);
|
||||
if (!excludeGroups && suggestedReviewers.size() < limit && !Strings.isNullOrEmpty(query)) {
|
||||
@@ -230,23 +231,25 @@ public class ReviewersUtil {
|
||||
|
||||
if (suggestedReviewers.size() > limit) {
|
||||
suggestedReviewers = suggestedReviewers.subList(0, limit);
|
||||
log.debug("Limited suggested reviewers to {} accounts.", limit);
|
||||
logger.atFine().log("Limited suggested reviewers to %d accounts.", limit);
|
||||
}
|
||||
log.debug(
|
||||
"Suggested reviewers: {}",
|
||||
suggestedReviewers
|
||||
.stream()
|
||||
.map(
|
||||
r -> {
|
||||
if (r.account != null) {
|
||||
return "a/" + r.account._accountId;
|
||||
} else if (r.group != null) {
|
||||
return "g/" + r.group.id;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
})
|
||||
.collect(toList()));
|
||||
logger
|
||||
.atFine()
|
||||
.log(
|
||||
"Suggested reviewers: %s",
|
||||
suggestedReviewers
|
||||
.stream()
|
||||
.map(
|
||||
r -> {
|
||||
if (r.account != null) {
|
||||
return "a/" + r.account._accountId;
|
||||
} else if (r.group != null) {
|
||||
return "g/" + r.group.id;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
})
|
||||
.collect(toList()));
|
||||
return suggestedReviewers;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.ParameterizedString;
|
||||
import com.google.gerrit.extensions.api.changes.SubmitInput;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -79,13 +80,11 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Submit
|
||||
implements RestModifyView<RevisionResource, SubmitInput>, UiAction<RevisionResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Submit.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final String DEFAULT_TOOLTIP = "Submit patch set ${patchSet} into ${branch}";
|
||||
private static final String DEFAULT_TOOLTIP_ANCESTORS =
|
||||
@@ -293,7 +292,7 @@ public class Submit
|
||||
+ unmergeable.stream().map(c -> c.getId().toString()).collect(joining(", "));
|
||||
}
|
||||
} catch (PermissionBackendException | OrmException | IOException e) {
|
||||
log.error("Error checking if change is submittable", e);
|
||||
logger.atSevere().withCause(e).log("Error checking if change is submittable");
|
||||
throw new OrmRuntimeException("Could not determine problems for the change", e);
|
||||
}
|
||||
return null;
|
||||
@@ -314,7 +313,7 @@ public class Submit
|
||||
return null; // submit not visible
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error checking if change is submittable", e);
|
||||
logger.atSevere().withCause(e).log("Error checking if change is submittable");
|
||||
throw new OrmRuntimeException("Could not determine problems for the change", e);
|
||||
}
|
||||
|
||||
@@ -325,7 +324,7 @@ public class Submit
|
||||
} catch (ResourceConflictException e) {
|
||||
return null; // submit not visible
|
||||
} catch (OrmException e) {
|
||||
log.error("Error checking if change is submittable", e);
|
||||
logger.atSevere().withCause(e).log("Error checking if change is submittable");
|
||||
throw new OrmRuntimeException("Could not determine problems for the change", e);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import static com.google.gerrit.extensions.api.changes.SubmittedTogetherOption.N
|
||||
import static java.util.Collections.reverseOrder;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.changes.SubmittedTogetherInfo;
|
||||
import com.google.gerrit.extensions.api.changes.SubmittedTogetherOption;
|
||||
import com.google.gerrit.extensions.client.ChangeStatus;
|
||||
@@ -47,11 +48,9 @@ import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SubmittedTogether.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final EnumSet<SubmittedTogetherOption> options =
|
||||
EnumSet.noneOf(SubmittedTogetherOption.class);
|
||||
@@ -155,7 +154,7 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
|
||||
info.nonVisibleChanges = hidden;
|
||||
return info;
|
||||
} catch (OrmException | IOException e) {
|
||||
log.error("Error on getting a ChangeSet", e);
|
||||
logger.atSevere().withCause(e).log("Error on getting a ChangeSet");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.common.Input;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
@@ -24,12 +25,10 @@ import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class Unignore implements RestModifyView<ChangeResource, Input>, UiAction<ChangeResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(Unignore.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final StarredChangesUtil stars;
|
||||
|
||||
@@ -59,7 +58,7 @@ public class Unignore implements RestModifyView<ChangeResource, Input>, UiAction
|
||||
try {
|
||||
return stars.isIgnored(rsrc);
|
||||
} catch (OrmException e) {
|
||||
log.error("failed to check ignored star", e);
|
||||
logger.atSevere().withCause(e).log("failed to check ignored star");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.config;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.ContributorAgreement;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.common.errors.NoSuchGroupException;
|
||||
@@ -26,11 +27,9 @@ import com.google.gerrit.server.restapi.group.GroupJson;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class AgreementJson {
|
||||
private static final Logger log = LoggerFactory.getLogger(AgreementJson.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final IdentifiedUser.GenericFactory identifiedUserFactory;
|
||||
@@ -62,12 +61,11 @@ public class AgreementJson {
|
||||
GroupResource group = new GroupResource(gc);
|
||||
info.autoVerifyGroup = groupJson.format(group);
|
||||
} catch (NoSuchGroupException | OrmException e) {
|
||||
log.warn(
|
||||
"autoverify group \""
|
||||
+ autoVerifyGroup.getName()
|
||||
+ "\" does not exist, referenced in CLA \""
|
||||
+ ca.getName()
|
||||
+ "\"");
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"autoverify group \"%s\" does not exist, referenced in CLA \"%s\"",
|
||||
autoVerifyGroup.getName(), ca.getName());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.config;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.config.CapabilityDefinition;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
@@ -29,13 +30,12 @@ import com.google.inject.Singleton;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** List capabilities visible to the calling user. */
|
||||
@Singleton
|
||||
public class ListCapabilities implements RestReadView<ConfigResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(ListCapabilities.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final Pattern PLUGIN_NAME_PATTERN = Pattern.compile("^[a-zA-Z0-9-]+$");
|
||||
|
||||
private final PermissionBackend permissionBackend;
|
||||
@@ -62,10 +62,11 @@ public class ListCapabilities implements RestReadView<ConfigResource> {
|
||||
Map<String, CapabilityInfo> output = new HashMap<>();
|
||||
for (String pluginName : pluginCapabilities.plugins()) {
|
||||
if (!PLUGIN_NAME_PATTERN.matcher(pluginName).matches()) {
|
||||
log.warn(
|
||||
"Plugin name '{}' must match '{}' to use capabilities; rename the plugin",
|
||||
pluginName,
|
||||
PLUGIN_NAME_PATTERN.pattern());
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"Plugin name '%s' must match '%s' to use capabilities; rename the plugin",
|
||||
pluginName, PLUGIN_NAME_PATTERN.pattern());
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<String, Provider<CapabilityDefinition>> entry :
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.config;
|
||||
|
||||
import static com.google.gerrit.server.config.ConfigUtil.skipField;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
||||
@@ -32,13 +33,11 @@ import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class SetDiffPreferences implements RestModifyView<ConfigResource, DiffPreferencesInfo> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetDiffPreferences.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
|
||||
private final AllUsersName allUsersName;
|
||||
@@ -82,7 +81,7 @@ public class SetDiffPreferences implements RestModifyView<ConfigResource, DiffPr
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn("Unable to verify input", e);
|
||||
logger.atWarning().withCause(e).log("Unable to verify input");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.config;
|
||||
|
||||
import static com.google.gerrit.server.config.ConfigUtil.skipField;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.extensions.client.EditPreferencesInfo;
|
||||
@@ -32,13 +33,11 @@ import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class SetEditPreferences implements RestModifyView<ConfigResource, EditPreferencesInfo> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetDiffPreferences.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
|
||||
private final AllUsersName allUsersName;
|
||||
@@ -82,7 +81,7 @@ public class SetEditPreferences implements RestModifyView<ConfigResource, EditPr
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn("Unable to verify input", e);
|
||||
logger.atSevere().withCause(e).log("Unable to verify input");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.config;
|
||||
|
||||
import static com.google.gerrit.server.config.ConfigUtil.skipField;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
@@ -32,13 +33,11 @@ import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class SetPreferences implements RestModifyView<ConfigResource, GeneralPreferencesInfo> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetPreferences.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Provider<MetaDataUpdate.User> metaDataUpdateFactory;
|
||||
private final AllUsersName allUsersName;
|
||||
@@ -79,7 +78,7 @@ public class SetPreferences implements RestModifyView<ConfigResource, GeneralPre
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn("Unable to verify input", e);
|
||||
logger.atSevere().withCause(e).log("Unable to verify input");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.group;
|
||||
|
||||
import static com.google.common.base.Strings.nullToEmpty;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.GroupDescription;
|
||||
import com.google.gerrit.common.errors.NoSuchGroupException;
|
||||
import com.google.gerrit.extensions.common.GroupInfo;
|
||||
@@ -30,12 +31,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ListSubgroups implements RestReadView<GroupResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(ListSubgroups.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final GroupControl.Factory controlFactory;
|
||||
private final GroupJson json;
|
||||
@@ -65,9 +64,9 @@ public class ListSubgroups implements RestReadView<GroupResource> {
|
||||
included.add(json.format(i.getGroup()));
|
||||
}
|
||||
} catch (NoSuchGroupException notFound) {
|
||||
log.warn(
|
||||
String.format(
|
||||
"Group %s no longer available, subgroup of %s", subgroupUuid, group.getName()));
|
||||
logger
|
||||
.atWarning()
|
||||
.log("Group %s no longer available, subgroup of %s", subgroupUuid, group.getName());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.restapi.project;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
@@ -41,12 +42,10 @@ import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class CommitsCollection implements ChildCollection<ProjectResource, CommitResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CommitsCollection.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final DynamicMap<RestView<CommitResource>> views;
|
||||
private final GitRepositoryManager repoManager;
|
||||
@@ -118,7 +117,10 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
|
||||
return true;
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
log.error("Cannot look up change for commit " + commit.name() + " in " + project, e);
|
||||
logger
|
||||
.atSevere()
|
||||
.withCause(e)
|
||||
.log("Cannot look up change for commit %s in %s", commit.name(), project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project;
|
||||
|
||||
import static com.google.gerrit.reviewdb.client.RefNames.isConfigRef;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInfo;
|
||||
import com.google.gerrit.extensions.api.projects.BranchInput;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -48,11 +49,9 @@ import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevObject;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CreateBranch implements RestModifyView<ProjectResource, BranchInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateBranch.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
CreateBranch create(String ref);
|
||||
@@ -193,7 +192,7 @@ public class CreateBranch implements RestModifyView<ProjectResource, BranchInput
|
||||
}
|
||||
return info;
|
||||
} catch (IOException err) {
|
||||
log.error("Cannot create branch \"" + name + "\"", err);
|
||||
logger.atSevere().withCause(err).log("Cannot create branch \"%s\"", name);
|
||||
throw err;
|
||||
}
|
||||
} catch (RefUtil.InvalidRevisionException e) {
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.ProjectUtil;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
@@ -86,17 +87,15 @@ import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.RefUpdate.Result;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@RequiresCapability(GlobalCapability.CREATE_PROJECT)
|
||||
public class CreateProject implements RestModifyView<TopLevelResource, ProjectInput> {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
CreateProject create(String name);
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateProject.class);
|
||||
|
||||
private final Provider<ProjectsCollection> projectsCollection;
|
||||
private final Provider<GroupsCollection> groupsCollection;
|
||||
private final DynamicSet<ProjectCreationValidationListener> projectCreationValidationListeners;
|
||||
@@ -275,7 +274,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
||||
throw new BadRequestException("invalid project name: " + nameKey);
|
||||
} catch (ConfigInvalidException e) {
|
||||
String msg = "Cannot create " + nameKey;
|
||||
log.error(msg, e);
|
||||
logger.atSevere().withCause(e).log(msg);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -383,7 +382,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Cannot create empty commit for " + project.get(), e);
|
||||
logger.atSevere().withCause(e).log("Cannot create empty commit for %s", project.get());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -398,7 +397,7 @@ public class CreateProject implements RestModifyView<TopLevelResource, ProjectIn
|
||||
try {
|
||||
l.onNewProjectCreated(event);
|
||||
} catch (RuntimeException e) {
|
||||
log.warn("Failure in NewProjectCreatedListener", e);
|
||||
logger.atWarning().withCause(e).log("Failure in NewProjectCreatedListener");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.restapi.project;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
import com.google.gerrit.extensions.api.projects.TagInfo;
|
||||
import com.google.gerrit.extensions.api.projects.TagInput;
|
||||
@@ -50,11 +51,9 @@ import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevObject;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CreateTag implements RestModifyView<ProjectResource, TagInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(CreateTag.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public interface Factory {
|
||||
CreateTag create(String ref);
|
||||
@@ -151,7 +150,7 @@ public class CreateTag implements RestModifyView<ProjectResource, TagInput> {
|
||||
} catch (InvalidRevisionException e) {
|
||||
throw new BadRequestException("Invalid base revision");
|
||||
} catch (GitAPIException e) {
|
||||
log.error("Cannot create tag \"" + ref + "\"", e);
|
||||
logger.atSevere().withCause(e).log("Cannot create tag \"%s\"", ref);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import static org.eclipse.jgit.lib.Constants.R_REFS;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
import static org.eclipse.jgit.transport.ReceiveCommand.Type.DELETE;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
@@ -50,11 +51,9 @@ import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand.Result;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class DeleteRef {
|
||||
private static final Logger log = LoggerFactory.getLogger(DeleteRef.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final int MAX_LOCK_FAILURE_CALLS = 10;
|
||||
private static final long SLEEP_ON_LOCK_FAILURE_MS = 15;
|
||||
@@ -138,7 +137,7 @@ public class DeleteRef {
|
||||
} catch (LockFailedException e) {
|
||||
result = RefUpdate.Result.LOCK_FAILURE;
|
||||
} catch (IOException e) {
|
||||
log.error("Cannot delete " + ref, e);
|
||||
logger.atSevere().withCause(e).log("Cannot delete %s", ref);
|
||||
throw e;
|
||||
}
|
||||
if (result == RefUpdate.Result.LOCK_FAILURE && --remainingLockFailureCalls > 0) {
|
||||
@@ -162,7 +161,7 @@ public class DeleteRef {
|
||||
break;
|
||||
|
||||
case REJECTED_CURRENT_BRANCH:
|
||||
log.error("Cannot delete " + ref + ": " + result.name());
|
||||
logger.atSevere().log("Cannot delete %s: %s", ref, result.name());
|
||||
throw new ResourceConflictException("cannot delete current branch");
|
||||
|
||||
case IO_FAILURE:
|
||||
@@ -173,7 +172,7 @@ public class DeleteRef {
|
||||
case REJECTED_MISSING_OBJECT:
|
||||
case REJECTED_OTHER_REASON:
|
||||
default:
|
||||
log.error("Cannot delete " + ref + ": " + result.name());
|
||||
logger.atSevere().log("Cannot delete %s: %s", ref, result.name());
|
||||
throw new ResourceConflictException("cannot delete: " + result.name());
|
||||
}
|
||||
}
|
||||
@@ -277,7 +276,7 @@ public class DeleteRef {
|
||||
msg = format("Cannot delete %s: %s", cmd.getRefName(), cmd.getResult());
|
||||
break;
|
||||
}
|
||||
log.error(msg);
|
||||
logger.atSevere().log(msg);
|
||||
errorMessages.append(msg);
|
||||
errorMessages.append("\n");
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import static java.util.stream.Collectors.toMap;
|
||||
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GroupDescription;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
@@ -67,12 +68,10 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class GetAccess implements RestReadView<ProjectResource> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GetAccess.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public static final ImmutableBiMap<PermissionRule.Action, PermissionRuleInfo.Action> ACTION_TYPE =
|
||||
ImmutableBiMap.of(
|
||||
@@ -290,7 +289,7 @@ public class GetAccess implements RestReadView<ProjectResource> {
|
||||
group.name = basic.getName();
|
||||
group.url = basic.getUrl();
|
||||
} else {
|
||||
LOG.warn("no such group: " + id);
|
||||
logger.atWarning().log("no such group: %s", id);
|
||||
group = null;
|
||||
}
|
||||
groups.put(id, group);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.project;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.projects.ReflogEntryInfo;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
@@ -36,11 +37,9 @@ import org.eclipse.jgit.lib.ReflogEntry;
|
||||
import org.eclipse.jgit.lib.ReflogReader;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class GetReflog implements RestReadView<BranchResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(GetReflog.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final PermissionBackend permissionBackend;
|
||||
@@ -106,7 +105,7 @@ public class GetReflog implements RestReadView<BranchResource> {
|
||||
r = repo.getReflogReader(rsrc.getRef());
|
||||
} catch (UnsupportedOperationException e) {
|
||||
String msg = "reflog not supported on repo " + rsrc.getNameKey().get();
|
||||
log.error(msg);
|
||||
logger.atSevere().log(msg);
|
||||
throw new MethodNotAllowedException(msg);
|
||||
}
|
||||
if (r == null) {
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project;
|
||||
|
||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_DASHBOARDS;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.projects.DashboardInfo;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
@@ -43,11 +44,9 @@ import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevWalk;
|
||||
import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ListDashboards implements RestReadView<ProjectResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(ListDashboards.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final GitRepositoryManager gitManager;
|
||||
private final PermissionBackend permissionBackend;
|
||||
@@ -139,10 +138,11 @@ public class ListDashboards implements RestReadView<ProjectResource> {
|
||||
project,
|
||||
setDefault));
|
||||
} catch (ConfigInvalidException e) {
|
||||
log.warn(
|
||||
String.format(
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"Cannot parse dashboard %s:%s:%s: %s",
|
||||
definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage()));
|
||||
definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.common.errors.NoSuchGroupException;
|
||||
@@ -79,12 +80,10 @@ import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.kohsuke.args4j.Option;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** List projects visible to the calling user. */
|
||||
public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(ListProjects.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
public enum FilterType {
|
||||
CODE {
|
||||
@@ -453,7 +452,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
// If the Git repository is gone, the project doesn't actually exist anymore.
|
||||
continue;
|
||||
} catch (IOException err) {
|
||||
log.warn("Unexpected error reading " + projectName, err);
|
||||
logger.atWarning().withCause(err).log("Unexpected error reading %s", projectName);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -557,9 +556,9 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
||||
if (projectCache.get(parent) != null) {
|
||||
return parent;
|
||||
}
|
||||
log.warn(
|
||||
String.format(
|
||||
"parent project %s of project %s not found", parent.get(), ps.getName()));
|
||||
logger
|
||||
.atWarning()
|
||||
.log("parent project %s of project %s not found", parent.get(), ps.getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.restapi.project;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInfo;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigInput;
|
||||
import com.google.gerrit.extensions.api.projects.ConfigValue;
|
||||
@@ -58,12 +59,11 @@ import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(PutConfig.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private static final Pattern PARAMETER_NAME_PATTERN =
|
||||
Pattern.compile("^[a-zA-Z0-9]+[a-zA-Z0-9-]*$");
|
||||
|
||||
@@ -164,7 +164,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
throw new ResourceConflictException(
|
||||
"Cannot update " + projectName + ": " + e.getCause().getMessage());
|
||||
}
|
||||
log.warn("Failed to update config of project {}.", projectName, e);
|
||||
logger.atWarning().withCause(e).log("Failed to update config of project %s.", projectName);
|
||||
throw new ResourceConflictException("Cannot update " + projectName);
|
||||
}
|
||||
|
||||
@@ -201,10 +201,11 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
if (projectConfigEntry != null) {
|
||||
if (!PARAMETER_NAME_PATTERN.matcher(v.getKey()).matches()) {
|
||||
// TODO check why we have this restriction
|
||||
log.warn(
|
||||
"Parameter name '{}' must match '{}'",
|
||||
v.getKey(),
|
||||
PARAMETER_NAME_PATTERN.pattern());
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"Parameter name '%s' must match '%s'",
|
||||
v.getKey(), PARAMETER_NAME_PATTERN.pattern());
|
||||
continue;
|
||||
}
|
||||
String oldValue = cfg.getString(v.getKey());
|
||||
@@ -252,10 +253,11 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
|
||||
cfg.setStringList(v.getKey(), v.getValue().values);
|
||||
break;
|
||||
default:
|
||||
log.warn(
|
||||
"The type '{}' of parameter '{}' is not supported.",
|
||||
projectConfigEntry.getType().name(),
|
||||
v.getKey());
|
||||
logger
|
||||
.atWarning()
|
||||
.log(
|
||||
"The type '%s' of parameter '%s' is not supported.",
|
||||
projectConfigEntry.getType().name(), v.getKey());
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new BadRequestException(
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.restapi.project;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.extensions.api.projects.HeadInput;
|
||||
import com.google.gerrit.extensions.events.HeadUpdatedListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
@@ -42,12 +43,10 @@ import org.eclipse.jgit.lib.Constants;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class SetHead implements RestModifyView<ProjectResource, HeadInput> {
|
||||
private static final Logger log = LoggerFactory.getLogger(SetHead.class);
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final GitRepositoryManager repoManager;
|
||||
private final Provider<IdentifiedUser> identifiedUser;
|
||||
@@ -128,7 +127,7 @@ public class SetHead implements RestModifyView<ProjectResource, HeadInput> {
|
||||
try {
|
||||
l.onHeadUpdated(event);
|
||||
} catch (RuntimeException e) {
|
||||
log.warn("Failure in HeadUpdatedListener", e);
|
||||
logger.atWarning().withCause(e).log("Failure in HeadUpdatedListener");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user