Reformat all Java files with google-java-format 1.6

Change-Id: Iedba3f24ac00e2186e3e0688fabea817ddf43739
This commit is contained in:
David Pursehouse
2018-06-06 10:26:51 +09:00
parent 399e9aa2aa
commit af864a0aad
193 changed files with 1331 additions and 1984 deletions

View File

@@ -72,9 +72,8 @@ public class AsciiDoctor {
private List<String> attributes = new ArrayList<>(); private List<String> attributes = new ArrayList<>();
@Option( @Option(
name = "--bazel", name = "--bazel",
usage = "bazel mode: generate multiple output files instead of a single zip file" usage = "bazel mode: generate multiple output files instead of a single zip file")
)
private boolean bazel; private boolean bazel;
@Option(name = "--revnumber-file", usage = "the file contains revnumber string") @Option(name = "--revnumber-file", usage = "the file contains revnumber string")

View File

@@ -294,12 +294,10 @@ public class PublicKeyChecker {
// Revoker is authorized and there is a revocation signature by this // Revoker is authorized and there is a revocation signature by this
// revoker, but the key is not in the store so we can't verify the // revoker, but the key is not in the store so we can't verify the
// signature. // signature.
logger logger.atInfo().log(
.atInfo() "Key %s is revoked by %s, which is not in the store. Assuming revocation is valid.",
.log( lazy(() -> Fingerprint.toString(key.getFingerprint())),
"Key %s is revoked by %s, which is not in the store. Assuming revocation is valid.", lazy(() -> Fingerprint.toString(rfp)));
lazy(() -> Fingerprint.toString(key.getFingerprint())),
lazy(() -> Fingerprint.toString(rfp)));
problems.add(reasonToString(getRevocationReason(revocation))); problems.add(reasonToString(getRevocationReason(revocation)));
continue; continue;
} }

View File

@@ -92,13 +92,11 @@ class SignedPushModule extends AbstractModule {
rp.setSignedPushConfig(null); rp.setSignedPushConfig(null);
return; return;
} else if (signedPushConfig == null) { } else if (signedPushConfig == null) {
logger logger.atSevere().log(
.atSevere() "receive.enableSignedPush is true for project %s but"
.log( + " false in gerrit.config, so signed push verification is"
"receive.enableSignedPush is true for project %s but" + " disabled",
+ " false in gerrit.config, so signed push verification is" project.get());
+ " disabled",
project.get());
rp.setSignedPushConfig(null); rp.setSignedPushConfig(null);
return; return;
} }

View File

@@ -163,9 +163,8 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> {
} }
} }
if (!found) { if (!found) {
logger logger.atWarning().log(
.atWarning() "No public key stored for fingerprint %s", Fingerprint.toString(fp));
.log("No public key stored for fingerprint %s", Fingerprint.toString(fp));
} }
} }
} }

View File

@@ -223,12 +223,9 @@ public class PostGpgKeys implements RestModifyView<AccountResource, GpgKeysInput
try { try {
addKeyFactory.create(rsrc.getUser(), addedKeys).send(); addKeyFactory.create(rsrc.getUser(), addedKeys).send();
} catch (EmailException e) { } catch (EmailException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Cannot send GPG key added message to %s",
.withCause(e) rsrc.getUser().getAccount().getPreferredEmail());
.log(
"Cannot send GPG key added message to %s",
rsrc.getUser().getAccount().getPreferredEmail());
} }
break; break;
case NO_CHANGE: case NO_CHANGE:

View File

@@ -130,11 +130,8 @@ class ProjectBasicAuthFilter implements Filter {
Optional<AccountState> accountState = Optional<AccountState> accountState =
accountCache.getByUsername(username).filter(a -> a.getAccount().isActive()); accountCache.getByUsername(username).filter(a -> a.getAccount().isActive());
if (!accountState.isPresent()) { if (!accountState.isPresent()) {
logger logger.atWarning().log(
.atWarning() "Authentication failed for %s: account inactive or not provisioned in Gerrit", username);
.log(
"Authentication failed for %s: account inactive or not provisioned in Gerrit",
username);
rsp.sendError(SC_UNAUTHORIZED); rsp.sendError(SC_UNAUTHORIZED);
return false; return false;
} }
@@ -186,11 +183,9 @@ class ProjectBasicAuthFilter implements Filter {
private boolean failAuthentication(Response rsp, String username, HttpServletRequest req) private boolean failAuthentication(Response rsp, String username, HttpServletRequest req)
throws IOException { throws IOException {
logger logger.atWarning().log(
.atWarning() authenticationFailedMsg(username, req)
.log( + ": password does not match the one stored in Gerrit");
authenticationFailedMsg(username, req)
+ ": password does not match the one stored in Gerrit");
rsp.sendError(SC_UNAUTHORIZED); rsp.sendError(SC_UNAUTHORIZED);
return false; return false;
} }

View File

@@ -154,11 +154,9 @@ class ProjectOAuthFilter implements Filter {
Optional<AccountState> who = Optional<AccountState> who =
accountCache.getByUsername(authInfo.username).filter(a -> a.getAccount().isActive()); accountCache.getByUsername(authInfo.username).filter(a -> a.getAccount().isActive());
if (!who.isPresent()) { if (!who.isPresent()) {
logger logger.atWarning().log(
.atWarning() authenticationFailedMsg(authInfo.username, req)
.log( + ": account inactive or not provisioned in Gerrit");
authenticationFailedMsg(authInfo.username, req)
+ ": account inactive or not provisioned in Gerrit");
rsp.sendError(SC_UNAUTHORIZED); rsp.sendError(SC_UNAUTHORIZED);
return false; return false;
} }

View File

@@ -68,11 +68,9 @@ public class WebSessionManager {
SECONDS.convert(MAX_AGE_MINUTES, MINUTES), SECONDS.convert(MAX_AGE_MINUTES, MINUTES),
SECONDS)); SECONDS));
if (sessionMaxAgeMillis < MINUTES.toMillis(5)) { if (sessionMaxAgeMillis < MINUTES.toMillis(5)) {
logger logger.atWarning().log(
.atWarning() "cache.%s.maxAge is set to %d milliseconds; it should be at least 5 minutes.",
.log( CACHE_NAME, sessionMaxAgeMillis);
"cache.%s.maxAge is set to %d milliseconds; it should be at least 5 minutes.",
CACHE_NAME, sessionMaxAgeMillis);
} }
} }

View File

@@ -85,12 +85,10 @@ class HttpLoginServlet extends HttpServlet {
CacheHeaders.setNotCacheable(rsp); CacheHeaders.setNotCacheable(rsp);
final String user = authFilter.getRemoteUser(req); final String user = authFilter.getRemoteUser(req);
if (user == null || "".equals(user)) { if (user == null || "".equals(user)) {
logger logger.atSevere().log(
.atSevere() "Unable to authenticate user by %s request header."
.log( + " Check container or server configuration.",
"Unable to authenticate user by %s request header." authFilter.getLoginHeader());
+ " Check container or server configuration.",
authFilter.getLoginHeader());
final Document doc = final Document doc =
HtmlDomUtil.parseFile( // HtmlDomUtil.parseFile( //
@@ -127,17 +125,12 @@ class HttpLoginServlet extends HttpServlet {
String remoteExternalId = authFilter.getRemoteExternalIdToken(req); String remoteExternalId = authFilter.getRemoteExternalIdToken(req);
if (remoteExternalId != null) { if (remoteExternalId != null) {
try { try {
logger logger.atFine().log(
.atFine() "Associating external identity \"%s\" to user \"%s\"", remoteExternalId, user);
.log("Associating external identity \"%s\" to user \"%s\"", remoteExternalId, user);
updateRemoteExternalId(arsp, remoteExternalId); updateRemoteExternalId(arsp, remoteExternalId);
} catch (AccountException | OrmException | ConfigInvalidException e) { } catch (AccountException | OrmException | ConfigInvalidException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Unable to associate external identity \"%s\" to user \"%s\"", remoteExternalId, user);
.withCause(e)
.log(
"Unable to associate external identity \"%s\" to user \"%s\"",
remoteExternalId, user);
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return; return;
} }

View File

@@ -174,13 +174,11 @@ class OAuthSession {
// This is (for now) a fatal error. There are two records // This is (for now) a fatal error. There are two records
// for what might be the same user. // for what might be the same user.
// //
logger logger.atSevere().log(
.atSevere() "OAuth accounts disagree over user identity:\n"
.log( + " Claimed ID: %s is %s\n"
"OAuth accounts disagree over user identity:\n" + " Delgate ID: %s is %s",
+ " Claimed ID: %s is %s\n" claimedId.get(), claimedIdentifier, actualId.get(), user.getExternalId());
+ " Delgate ID: %s is %s",
claimedId.get(), claimedIdentifier, actualId.get(), user.getExternalId());
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false; return false;
} }
@@ -191,11 +189,9 @@ class OAuthSession {
try { try {
accountManager.link(claimedId.get(), req); accountManager.link(claimedId.get(), req);
} catch (OrmException | ConfigInvalidException e) { } catch (OrmException | ConfigInvalidException e) {
logger logger.atSevere().log(
.atSevere() "Cannot link: %s to user identity:\n Claimed ID: %s is %s",
.log( user.getExternalId(), claimedId.get(), claimedIdentifier);
"Cannot link: %s to user identity:\n Claimed ID: %s is %s",
user.getExternalId(), claimedId.get(), claimedIdentifier);
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false; return false;
} }
@@ -208,11 +204,9 @@ class OAuthSession {
try { try {
accountManager.link(identifiedUser.get().getAccountId(), areq); accountManager.link(identifiedUser.get().getAccountId(), areq);
} catch (OrmException | ConfigInvalidException e) { } catch (OrmException | ConfigInvalidException e) {
logger logger.atSevere().log(
.atSevere() "Cannot link: %s to user identity: %s",
.log( user.getExternalId(), identifiedUser.get().getAccountId());
"Cannot link: %s to user identity: %s",
user.getExternalId(), identifiedUser.get().getAccountId());
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return false; return false;
} finally { } finally {

View File

@@ -151,13 +151,11 @@ class OAuthSessionOverOpenID {
// This is (for now) a fatal error. There are two records // This is (for now) a fatal error. There are two records
// for what might be the same user. The admin would have to // for what might be the same user. The admin would have to
// link the accounts manually. // link the accounts manually.
logger logger.atFine().log(
.atFine() "OAuth accounts disagree over user identity:\n"
.log( + " Claimed ID: %s is %s\n"
"OAuth accounts disagree over user identity:\n" + " Delgate ID: %s is %s",
+ " Claimed ID: %s is %s\n" claimedId.get(), claimedIdentifier, actualId.get(), user.getExternalId());
+ " Delgate ID: %s is %s",
claimedId.get(), claimedIdentifier, actualId.get(), user.getExternalId());
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return; return;
} }
@@ -167,11 +165,9 @@ class OAuthSessionOverOpenID {
try { try {
accountManager.link(claimedId.get(), areq); accountManager.link(claimedId.get(), areq);
} catch (OrmException | ConfigInvalidException e) { } catch (OrmException | ConfigInvalidException e) {
logger logger.atSevere().log(
.atSevere() "Cannot link: %s to user identity:\n Claimed ID: %s is %s",
.log( user.getExternalId(), claimedId.get(), claimedIdentifier);
"Cannot link: %s to user identity:\n Claimed ID: %s is %s",
user.getExternalId(), claimedId.get(), claimedIdentifier);
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return; return;
} }
@@ -183,9 +179,8 @@ class OAuthSessionOverOpenID {
logger.atFine().log("Linking \"%s\" to \"%s\"", user.getExternalId(), accountId); logger.atFine().log("Linking \"%s\" to \"%s\"", user.getExternalId(), accountId);
accountManager.link(accountId, areq); accountManager.link(accountId, areq);
} catch (OrmException | ConfigInvalidException e) { } catch (OrmException | ConfigInvalidException e) {
logger logger.atSevere().log(
.atSevere() "Cannot link: %s to user identity: %s", user.getExternalId(), accountId);
.log("Cannot link: %s to user identity: %s", user.getExternalId(), accountId);
rsp.sendError(HttpServletResponse.SC_FORBIDDEN); rsp.sendError(HttpServletResponse.SC_FORBIDDEN);
return; return;
} finally { } finally {

View File

@@ -249,12 +249,10 @@ class OpenIdServiceImpl {
if ("Nonce verification failed.".equals(result.getStatusMsg())) { if ("Nonce verification failed.".equals(result.getStatusMsg())) {
// We might be suffering from clock skew on this system. // We might be suffering from clock skew on this system.
// //
logger logger.atSevere().log(
.atSevere() "OpenID failure: %s Likely caused by clock skew on this server,"
.log( + " install/configure NTP.",
"OpenID failure: %s Likely caused by clock skew on this server," result.getStatusMsg());
+ " install/configure NTP.",
result.getStatusMsg());
cancelWithError(req, rsp, result.getStatusMsg()); cancelWithError(req, rsp, result.getStatusMsg());
} else if (result.getStatusMsg() != null) { } else if (result.getStatusMsg() != null) {
@@ -376,13 +374,11 @@ class OpenIdServiceImpl {
// This is (for now) a fatal error. There are two records // This is (for now) a fatal error. There are two records
// for what might be the same user. // for what might be the same user.
// //
logger logger.atSevere().log(
.atSevere() "OpenID accounts disagree over user identity:\n"
.log( + " Claimed ID: %s is %s\n"
"OpenID accounts disagree over user identity:\n" + " Delgate ID: %s is %s",
+ " Claimed ID: %s is %s\n" claimedId.get(), claimedIdentifier, actualId.get(), areq.getExternalIdKey());
+ " Delgate ID: %s is %s",
claimedId.get(), claimedIdentifier, actualId.get(), areq.getExternalIdKey());
cancelWithError(req, rsp, "Contact site administrator"); cancelWithError(req, rsp, "Contact site administrator");
return; return;
} }

View File

@@ -423,12 +423,9 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
&& (name.endsWith(".md") || name.endsWith(".html")) && (name.endsWith(".md") || name.endsWith(".html"))
&& size.isPresent()) { && size.isPresent()) {
if (size.get() <= 0 || size.get() > SMALL_RESOURCE) { if (size.get() <= 0 || size.get() > SMALL_RESOURCE) {
logger logger.atWarning().log(
.atWarning() "Plugin %s: %s omitted from document index. " + "Size %d out of range (0,%d).",
.log( pluginName, name.substring(prefix.length()), size.get(), SMALL_RESOURCE);
"Plugin %s: %s omitted from document index. "
+ "Size %d out of range (0,%d).",
pluginName, name.substring(prefix.length()), size.get(), SMALL_RESOURCE);
return false; return false;
} }
return true; return true;
@@ -450,11 +447,9 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
if (about == null) { if (about == null) {
about = entry; about = entry;
} else { } else {
logger logger.atWarning().log(
.atWarning() "Plugin %s: Multiple 'about' documents found; using %s",
.log( pluginName, about.getName().substring(prefix.length()));
"Plugin %s: Multiple 'about' documents found; using %s",
pluginName, about.getName().substring(prefix.length()));
} }
} else { } else {
docs.add(entry); docs.add(entry);
@@ -732,10 +727,8 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
} }
return def; return def;
} catch (IOException e) { } catch (IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Error getting %s for plugin %s, using default", attr, plugin.getName());
.withCause(e)
.log("Error getting %s for plugin %s, using default", attr, plugin.getName());
return null; return null;
} }
} }

View File

@@ -183,10 +183,8 @@ public class Schema<T> {
try { try {
v = f.get(obj); v = f.get(obj);
} catch (OrmException e) { } catch (OrmException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "error getting field %s of %s", f.getName(), obj);
.withCause(e)
.log("error getting field %s of %s", f.getName(), obj);
return null; return null;
} }
if (v == null) { if (v == null) {

View File

@@ -150,13 +150,10 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
try { try {
autoCommitWriter.close(); autoCommitWriter.close();
} catch (IOException e2) { } catch (IOException e2) {
logger logger.atSevere().withCause(e).log(
.atSevere() "SEVERE: Error closing %s Lucene index after OOM;"
.withCause(e) + " index may be corrupted.",
.log( index);
"SEVERE: Error closing %s Lucene index after OOM;"
+ " index may be corrupted.",
index);
} }
} }
}, },
@@ -230,10 +227,8 @@ public abstract class AbstractLuceneIndex<K, V> implements Index<K, V> {
logger.atWarning().log("shutting down %s index with pending Lucene writes", name); logger.atWarning().log("shutting down %s index with pending Lucene writes", name);
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "interrupted waiting for pending Lucene writes of %s index", name);
.withCause(e)
.log("interrupted waiting for pending Lucene writes of %s index", name);
} }
reopenThread.close(); reopenThread.close();

View File

@@ -37,11 +37,10 @@ class ListMetrics implements RestReadView<ConfigResource> {
boolean dataOnly; boolean dataOnly;
@Option( @Option(
name = "--prefix", name = "--prefix",
aliases = {"-p"}, aliases = {"-p"},
metaVar = "PREFIX", metaVar = "PREFIX",
usage = "match metric by exact match or prefix" usage = "match metric by exact match or prefix")
)
List<String> query = new ArrayList<>(); List<String> query = new ArrayList<>();
@Inject @Inject

View File

@@ -168,20 +168,18 @@ public class Daemon extends SiteProgram {
private boolean polyGerritDev; private boolean polyGerritDev;
@Option( @Option(
name = "--init", name = "--init",
aliases = {"-i"}, aliases = {"-i"},
usage = "Init site before starting the daemon" usage = "Init site before starting the daemon")
)
private boolean doInit; private boolean doInit;
@Option(name = "--stop-only", usage = "Stop the daemon", hidden = true) @Option(name = "--stop-only", usage = "Stop the daemon", hidden = true)
private boolean stopOnly; private boolean stopOnly;
@Option( @Option(
name = "--migrate-to-note-db", name = "--migrate-to-note-db",
usage = "Automatically migrate changes to NoteDb", usage = "Automatically migrate changes to NoteDb",
handler = ExplicitBooleanOptionHandler.class handler = ExplicitBooleanOptionHandler.class)
)
private boolean migrateToNoteDb; private boolean migrateToNoteDb;
@Option(name = "--trial", usage = "(With --migrate-to-note-db) " + MigrateToNoteDb.TRIAL_USAGE) @Option(name = "--trial", usage = "(With --migrate-to-note-db) " + MigrateToNoteDb.TRIAL_USAGE)

View File

@@ -44,10 +44,9 @@ import org.kohsuke.args4j.Option;
/** Initialize a new Gerrit installation. */ /** Initialize a new Gerrit installation. */
public class Init extends BaseInit { public class Init extends BaseInit {
@Option( @Option(
name = "--batch", name = "--batch",
aliases = {"-b"}, aliases = {"-b"},
usage = "Batch mode; skip interactive prompting" usage = "Batch mode; skip interactive prompting")
)
private boolean batchMode; private boolean batchMode;
@Option(name = "--delete-caches", usage = "Delete all persistent caches without asking") @Option(name = "--delete-caches", usage = "Delete all persistent caches without asking")
@@ -69,9 +68,8 @@ public class Init extends BaseInit {
private boolean installAllPlugins; private boolean installAllPlugins;
@Option( @Option(
name = "--secure-store-lib", name = "--secure-store-lib",
usage = "Path to jar providing SecureStore implementation class" usage = "Path to jar providing SecureStore implementation class")
)
private String secureStoreLib; private String secureStoreLib;
@Option(name = "--dev", usage = "Setup site with default options suitable for developers") @Option(name = "--dev", usage = "Setup site with default options suitable for developers")

View File

@@ -188,11 +188,8 @@ public class JythonShell {
new Class<?>[] {String.class}, new Class<?>[] {String.class},
new Object[] {script.getAbsolutePath()}); new Object[] {script.getAbsolutePath()});
} else { } else {
logger logger.atInfo().log(
.atInfo() "User initialization file %s is not found or not executable", script.getAbsolutePath());
.log(
"User initialization file %s is not found or not executable",
script.getAbsolutePath());
} }
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
logger.atSevere().withCause(e).log("Exception occurred while loading file %s", p); logger.atSevere().withCause(e).log("Exception occurred while loading file %s", p);

View File

@@ -43,9 +43,8 @@ public class MigrateAccountPatchReviewDb extends SiteProgram {
private String sourceUrl; private String sourceUrl;
@Option( @Option(
name = "--chunkSize", name = "--chunkSize",
usage = "chunk size of fetching from source and push to target on each time" usage = "chunk size of fetching from source and push to target on each time")
)
private static long chunkSize = 100000; private static long chunkSize = 100000;
@Override @Override

View File

@@ -55,46 +55,42 @@ public class MigrateToNoteDb extends SiteProgram {
private Integer threads; private Integer threads;
@Option( @Option(
name = "--project", name = "--project",
usage = usage =
"Only rebuild these projects, do no other migration; incompatible with --change;" "Only rebuild these projects, do no other migration; incompatible with --change;"
+ " recommended for debugging only" + " recommended for debugging only")
)
private List<String> projects = new ArrayList<>(); private List<String> projects = new ArrayList<>();
@Option( @Option(
name = "--change", name = "--change",
usage = usage =
"Only rebuild these changes, do no other migration; incompatible with --project;" "Only rebuild these changes, do no other migration; incompatible with --project;"
+ " recommended for debugging only" + " recommended for debugging only")
)
private List<Integer> changes = new ArrayList<>(); private List<Integer> changes = new ArrayList<>();
@Option( @Option(
name = "--force", name = "--force",
usage = usage =
"Force rebuilding changes where ReviewDb is still the source of truth, even if they" "Force rebuilding changes where ReviewDb is still the source of truth, even if they"
+ " were previously migrated" + " were previously migrated")
)
private boolean force; private boolean force;
@Option(name = "--trial", usage = TRIAL_USAGE) @Option(name = "--trial", usage = TRIAL_USAGE)
private boolean trial; private boolean trial;
@Option( @Option(
name = "--sequence-gap", name = "--sequence-gap",
usage = usage =
"gap in change sequence numbers between last ReviewDb number and first NoteDb number;" "gap in change sequence numbers between last ReviewDb number and first NoteDb number;"
+ " negative indicates using the value of noteDb.changes.initialSequenceGap (default" + " negative indicates using the value of noteDb.changes.initialSequenceGap (default"
+ " 1000)" + " 1000)")
)
private int sequenceGap; private int sequenceGap;
@Option( @Option(
name = "--reindex", name = "--reindex",
usage = "Reindex all changes after migration; defaults to false in trial mode, true otherwise", usage =
handler = ExplicitBooleanOptionHandler.class "Reindex all changes after migration; defaults to false in trial mode, true otherwise",
) handler = ExplicitBooleanOptionHandler.class)
private Boolean reindex; private Boolean reindex;
private Injector dbInjector; private Injector dbInjector;

View File

@@ -39,11 +39,10 @@ public class Passwd extends SiteProgram {
private String key; private String key;
@Argument( @Argument(
metaVar = "SECTION.KEY", metaVar = "SECTION.KEY",
index = 0, index = 0,
required = true, required = true,
usage = "Section and key separated by a dot of the password to set" usage = "Section and key separated by a dot of the password to set")
)
private String sectionAndKey; private String sectionAndKey;
@Argument(metaVar = "PASSWORD", index = 1, required = false, usage = "Password to set") @Argument(metaVar = "PASSWORD", index = 1, required = false, usage = "Password to set")

View File

@@ -32,12 +32,11 @@ import org.kohsuke.args4j.Option;
public class ProtoGen extends AbstractProgram { public class ProtoGen extends AbstractProgram {
@Option( @Option(
name = "--output", name = "--output",
aliases = {"-o"}, aliases = {"-o"},
required = true, required = true,
metaVar = "FILE", metaVar = "FILE",
usage = "File to write .proto into" usage = "File to write .proto into")
)
private File file; private File file;
@Override @Override

View File

@@ -65,12 +65,11 @@ import org.kohsuke.args4j.Option;
*/ */
public class ProtobufImport extends SiteProgram { public class ProtobufImport extends SiteProgram {
@Option( @Option(
name = "--file", name = "--file",
aliases = {"-f"}, aliases = {"-f"},
required = true, required = true,
metaVar = "FILE", metaVar = "FILE",
usage = "File to import from" usage = "File to import from")
)
private File file; private File file;
private final LifecycleManager manager = new LifecycleManager(); private final LifecycleManager manager = new LifecycleManager();

View File

@@ -57,9 +57,8 @@ public class Reindex extends SiteProgram {
private int threads = Runtime.getRuntime().availableProcessors(); private int threads = Runtime.getRuntime().availableProcessors();
@Option( @Option(
name = "--changes-schema-version", name = "--changes-schema-version",
usage = "Schema version to reindex, for changes; default is most recent version" usage = "Schema version to reindex, for changes; default is most recent version")
)
private Integer changesVersion; private Integer changesVersion;
@Option(name = "--verbose", usage = "Output debug information for each change") @Option(name = "--verbose", usage = "Output debug information for each change")

View File

@@ -44,11 +44,10 @@ public class Rulec extends SiteProgram {
private boolean quiet; private boolean quiet;
@Argument( @Argument(
index = 0, index = 0,
multiValued = true, multiValued = true,
metaVar = "PROJECT", metaVar = "PROJECT",
usage = "project to compile rules for" usage = "project to compile rules for")
)
private List<String> projectNames = new ArrayList<>(); private List<String> projectNames = new ArrayList<>();
private Injector dbInjector; private Injector dbInjector;

View File

@@ -56,10 +56,9 @@ public class SwitchSecureStore extends SiteProgram {
} }
@Option( @Option(
name = "--new-secure-store-lib", name = "--new-secure-store-lib",
usage = "Path to new SecureStore implementation", usage = "Path to new SecureStore implementation",
required = true required = true)
)
private String newSecureStoreLib; private String newSecureStoreLib;
@Override @Override
@@ -75,22 +74,18 @@ public class SwitchSecureStore extends SiteProgram {
String currentSecureStoreName = getCurrentSecureStoreClassName(sitePaths); String currentSecureStoreName = getCurrentSecureStoreClassName(sitePaths);
if (currentSecureStoreName.equals(newSecureStore)) { if (currentSecureStoreName.equals(newSecureStore)) {
logger logger.atSevere().log(
.atSevere() "Old and new SecureStore implementation names "
.log( + "are the same. Migration will not work");
"Old and new SecureStore implementation names "
+ "are the same. Migration will not work");
return -1; return -1;
} }
IoUtil.loadJARs(newSecureStorePath); IoUtil.loadJARs(newSecureStorePath);
SiteLibraryLoaderUtil.loadSiteLib(sitePaths.lib_dir); SiteLibraryLoaderUtil.loadSiteLib(sitePaths.lib_dir);
logger logger.atInfo().log(
.atInfo() "Current secureStoreClass property (%s) will be replaced with %s",
.log( currentSecureStoreName, newSecureStore);
"Current secureStoreClass property (%s) will be replaced with %s",
currentSecureStoreName, newSecureStore);
Injector dbInjector = createDbInjector(SINGLE_USER); Injector dbInjector = createDbInjector(SINGLE_USER);
SecureStore currentStore = getSecureStore(currentSecureStoreName, dbInjector); SecureStore currentStore = getSecureStore(currentSecureStoreName, dbInjector);
SecureStore newStore = getSecureStore(newSecureStore, dbInjector); SecureStore newStore = getSecureStore(newSecureStore, dbInjector);
@@ -125,35 +120,29 @@ public class SwitchSecureStore extends SiteProgram {
private void removeOldLib(SitePaths sitePaths, String currentSecureStoreName) throws IOException { private void removeOldLib(SitePaths sitePaths, String currentSecureStoreName) throws IOException {
Path oldSecureStore = findJarWithSecureStore(sitePaths, currentSecureStoreName); Path oldSecureStore = findJarWithSecureStore(sitePaths, currentSecureStoreName);
if (oldSecureStore != null) { if (oldSecureStore != null) {
logger logger.atInfo().log(
.atInfo() "Removing old SecureStore (%s) from lib/ directory", oldSecureStore.getFileName());
.log("Removing old SecureStore (%s) from lib/ directory", oldSecureStore.getFileName());
try { try {
Files.delete(oldSecureStore); Files.delete(oldSecureStore);
} catch (IOException e) { } catch (IOException e) {
logger.atSevere().withCause(e).log("Cannot remove %s", oldSecureStore.toAbsolutePath()); logger.atSevere().withCause(e).log("Cannot remove %s", oldSecureStore.toAbsolutePath());
} }
} else { } else {
logger logger.atInfo().log(
.atInfo() "Cannot find jar with old SecureStore (%s) in lib/ directory", currentSecureStoreName);
.log(
"Cannot find jar with old SecureStore (%s) in lib/ directory",
currentSecureStoreName);
} }
} }
private void copyNewLib(SitePaths sitePaths, Path newSecureStorePath) throws IOException { private void copyNewLib(SitePaths sitePaths, Path newSecureStorePath) throws IOException {
logger logger.atInfo().log(
.atInfo() "Copy new SecureStore (%s) into lib/ directory", newSecureStorePath.getFileName());
.log("Copy new SecureStore (%s) into lib/ directory", newSecureStorePath.getFileName());
Files.copy(newSecureStorePath, sitePaths.lib_dir.resolve(newSecureStorePath.getFileName())); Files.copy(newSecureStorePath, sitePaths.lib_dir.resolve(newSecureStorePath.getFileName()));
} }
private void updateGerritConfig(SitePaths sitePaths, String newSecureStore) private void updateGerritConfig(SitePaths sitePaths, String newSecureStore)
throws IOException, ConfigInvalidException { throws IOException, ConfigInvalidException {
logger logger.atInfo().log(
.atInfo() "Set gerrit.secureStoreClass property of gerrit.config to %s", newSecureStore);
.log("Set gerrit.secureStoreClass property of gerrit.config to %s", newSecureStore);
FileBasedConfig config = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED); FileBasedConfig config = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
config.load(); config.load();
config.setString("gerrit", null, "secureStoreClass", newSecureStore); config.setString("gerrit", null, "secureStoreClass", newSecureStore);

View File

@@ -204,9 +204,8 @@ public class BaseInit extends SiteProgram {
} }
return names; return names;
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
logger logger.atWarning().log(
.atWarning() "Couldn't find distribution archive location. No plugin will be installed");
.log("Couldn't find distribution archive location. No plugin will be installed");
return null; return null;
} }
} }

View File

@@ -64,9 +64,8 @@ public class AllProjectsConfig extends VersionedMetaDataOnInit {
new Project.NameKey(project), new Project.NameKey(project),
readUTF8(GroupList.FILE_NAME), readUTF8(GroupList.FILE_NAME),
error -> error ->
logger logger.atSevere().log(
.atSevere() "Error parsing file %s: %s", GroupList.FILE_NAME, error.getMessage()));
.log("Error parsing file %s: %s", GroupList.FILE_NAME, error.getMessage()));
} }
public void save(String pluginName, String message) throws IOException, ConfigInvalidException { public void save(String pluginName, String message) throws IOException, ConfigInvalidException {

View File

@@ -65,10 +65,9 @@ import org.kohsuke.args4j.Option;
public abstract class SiteProgram extends AbstractProgram { public abstract class SiteProgram extends AbstractProgram {
@Option( @Option(
name = "--site-path", name = "--site-path",
aliases = {"-d"}, aliases = {"-d"},
usage = "Local directory containing site data" usage = "Local directory containing site data")
)
private void setSitePath(String path) { private void setSitePath(String path) {
sitePath = Paths.get(path); sitePath = Paths.get(path);
} }

View File

@@ -270,12 +270,9 @@ public class ApprovalsUtil {
.database(db) .database(db)
.test(ChangePermission.READ); .test(ChangePermission.READ);
} catch (IOException | PermissionBackendException e) { } catch (IOException | PermissionBackendException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Failed to check if account %d can see change %d",
.withCause(e) accountId.get(), notes.getChangeId().get());
.log(
"Failed to check if account %d can see change %d",
accountId.get(), notes.getChangeId().get());
return false; return false;
} }
} }

View File

@@ -304,12 +304,9 @@ public class StarredChangesUtil {
Ref ref = repo.exactRef(RefNames.refsStarredChanges(changeId, accountId)); Ref ref = repo.exactRef(RefNames.refsStarredChanges(changeId, accountId));
return ref != null ? ref.getObjectId() : ObjectId.zeroId(); return ref != null ? ref.getObjectId() : ObjectId.zeroId();
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Getting star object ID for account %d on change %d failed",
.withCause(e) accountId.get(), changeId.get());
.log(
"Getting star object ID for account %d on change %d failed",
accountId.get(), changeId.get());
return ObjectId.zeroId(); return ObjectId.zeroId();
} }
} }

View File

@@ -91,16 +91,11 @@ public class AccountDeactivator implements Runnable {
numberOfAccountsDeactivated++; numberOfAccountsDeactivated++;
} }
} }
logger logger.atInfo().log(
.atInfo() "Deactivations complete, %d account(s) were deactivated", numberOfAccountsDeactivated);
.log(
"Deactivations complete, %d account(s) were deactivated",
numberOfAccountsDeactivated);
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Failed to complete deactivation of accounts: %s", e.getMessage());
.withCause(e)
.log("Failed to complete deactivation of accounts: %s", e.getMessage());
} }
} }
@@ -120,12 +115,9 @@ public class AccountDeactivator implements Runnable {
} catch (ResourceConflictException e) { } catch (ResourceConflictException e) {
logger.atInfo().log("Account %s already deactivated, continuing...", userName); logger.atInfo().log("Account %s already deactivated, continuing...", userName);
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Error deactivating account: %s (%s) %s",
.withCause(e) userName, accountState.getAccount().getId(), e.getMessage());
.log(
"Error deactivating account: %s (%s) %s",
userName, accountState.getAccount().getId(), e.getMessage());
} }
return false; return false;
} }

View File

@@ -143,11 +143,9 @@ public class AccountManager {
// An inconsistency is detected in the database, having a record for scheme "username:" // An inconsistency is detected in the database, having a record for scheme "username:"
// but no record for scheme "gerrit:". Try to recover by linking // but no record for scheme "gerrit:". Try to recover by linking
// "gerrit:" identity to the existing account. // "gerrit:" identity to the existing account.
logger logger.atWarning().log(
.atWarning() "User %s already has an account; link new identity to the existing account.",
.log( who.getUserName());
"User %s already has an account; link new identity to the existing account.",
who.getUserName());
return link(existingId.get().accountId(), who); return link(existingId.get().accountId(), who);
} }
} }
@@ -159,11 +157,9 @@ public class AccountManager {
ExternalId extId = optionalExtId.get(); ExternalId extId = optionalExtId.get();
Optional<AccountState> accountState = byIdCache.get(extId.accountId()); Optional<AccountState> accountState = byIdCache.get(extId.accountId());
if (!accountState.isPresent()) { if (!accountState.isPresent()) {
logger logger.atSevere().log(
.atSevere() "Authentication with external ID %s failed. Account %s doesn't exist.",
.log( extId.key().get(), extId.accountId().get());
"Authentication with external ID %s failed. Account %s doesn't exist.",
extId.key().get(), extId.accountId().get());
throw new AccountException("Authentication error, account not found"); throw new AccountException("Authentication error, account not found");
} }
@@ -197,14 +193,11 @@ public class AccountManager {
} }
setInactiveFlag.deactivate(extId.get().accountId()); setInactiveFlag.deactivate(extId.get().accountId());
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Unable to deactivate account %s",
.withCause(e) authRequest
.log( .getUserName()
"Unable to deactivate account %s", .orElse(" for external ID key " + authRequest.getExternalIdKey().get()));
authRequest
.getUserName()
.orElse(" for external ID key " + authRequest.getExternalIdKey().get()));
} }
} }
@@ -265,11 +258,9 @@ public class AccountManager {
&& who.getUserName().isPresent() && who.getUserName().isPresent()
&& !who.getUserName().equals(user.getUserName())) { && !who.getUserName().equals(user.getUserName())) {
if (user.getUserName().isPresent()) { if (user.getUserName().isPresent()) {
logger logger.atWarning().log(
.atWarning() "Not changing already set username %s to %s",
.log( user.getUserName().get(), who.getUserName().get());
"Not changing already set username %s to %s",
user.getUserName().get(), who.getUserName().get());
} else { } else {
logger.atWarning().log("Not setting username to %s", who.getUserName().get()); logger.atWarning().log("Not setting username to %s", who.getUserName().get());
} }
@@ -381,15 +372,13 @@ public class AccountManager {
return; return;
} }
logger logger.atWarning().log(
.atWarning() "Email %s is already assigned to account %s;"
.log( + " cannot create external ID %s with the same email for account %s.",
"Email %s is already assigned to account %s;" email,
+ " cannot create external ID %s with the same email for account %s.", existingExtIdsWithEmail.iterator().next().accountId().get(),
email, extIdToBeCreated.key().get(),
existingExtIdsWithEmail.iterator().next().accountId().get(), extIdToBeCreated.accountId().get());
extIdToBeCreated.key().get(),
extIdToBeCreated.accountId().get());
throw new AccountException("Email '" + email + "' in use by another account"); throw new AccountException("Email '" + email + "' in use by another account");
} }

View File

@@ -52,9 +52,8 @@ public class VersionedAccountQueries extends VersionedMetaData {
QueryList.parse( QueryList.parse(
readUTF8(QueryList.FILE_NAME), readUTF8(QueryList.FILE_NAME),
error -> error ->
logger logger.atSevere().log(
.atSevere() "Error parsing file %s: %s", QueryList.FILE_NAME, error.getMessage()));
.log("Error parsing file %s: %s", QueryList.FILE_NAME, error.getMessage()));
} }
@Override @Override

View File

@@ -357,10 +357,8 @@ public class ExternalIdNotes extends VersionedMetaData {
try { try {
b.add(ExternalId.parse(note.getName(), raw, note.getData())); b.add(ExternalId.parse(note.getName(), raw, note.getData()));
} catch (ConfigInvalidException | RuntimeException e) { } catch (ConfigInvalidException | RuntimeException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Ignoring invalid external ID note %s", note.getName());
.withCause(e)
.log("Ignoring invalid external ID note %s", note.getName());
} }
} }
return b.build(); return b.build();

View File

@@ -475,13 +475,10 @@ class Helper {
try { try {
return LdapType.guessType(ctx); return LdapType.guessType(ctx);
} catch (NamingException e) { } catch (NamingException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot discover type of LDAP server at %s,"
.withCause(e) + " assuming the server is RFC 2307 compliant.",
.log( server);
"Cannot discover type of LDAP server at %s,"
+ " assuming the server is RFC 2307 compliant.",
server);
return LdapType.RFC_2307; return LdapType.RFC_2307;
} }
} }

View File

@@ -346,12 +346,10 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements Per
// most likely bumping serialVersionUID rather than using the new versioning in the // most likely bumping serialVersionUID rather than using the new versioning in the
// CacheBinding. That's ok; we'll continue to support both for now. // CacheBinding. That's ok; we'll continue to support both for now.
// TODO(dborowitz): Remove this case when Java serialization is no longer used. // TODO(dborowitz): Remove this case when Java serialization is no longer used.
logger logger.atWarning().log(
.atWarning() "Entries cached for %s have an incompatible class and can't be deserialized. "
.log( + "Cache is flushed.",
"Entries cached for %s have an incompatible class and can't be deserialized. " url);
+ "Cache is flushed.",
url);
invalidateAll(); invalidateAll();
} else { } else {
throw e; throw e;
@@ -531,11 +529,8 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements Per
try (PreparedStatement ps = c.conn.prepareStatement("DELETE FROM data WHERE version!=?")) { try (PreparedStatement ps = c.conn.prepareStatement("DELETE FROM data WHERE version!=?")) {
ps.setInt(1, version); ps.setInt(1, version);
int oldEntries = ps.executeUpdate(); int oldEntries = ps.executeUpdate();
logger logger.atInfo().log(
.atInfo() "Pruned %d entries not matching version %d from cache %s", oldEntries, version, url);
.log(
"Pruned %d entries not matching version %d from cache %s",
oldEntries, version, url);
} }
try (Statement s = c.conn.createStatement()) { try (Statement s = c.conn.createStatement()) {
// Compute size without restricting to version (although obsolete data was just pruned // Compute size without restricting to version (although obsolete data was just pruned

View File

@@ -97,10 +97,8 @@ public class AbandonUtil {
} }
logger.atInfo().log("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size()); logger.atInfo().log("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size());
} catch (QueryParseException | OrmException e) { } catch (QueryParseException | OrmException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Failed to query inactive open changes for auto-abandoning.");
.withCause(e)
.log("Failed to query inactive open changes for auto-abandoning.");
} }
} }
@@ -118,12 +116,10 @@ public class AbandonUtil {
if (!changesToAbandon.isEmpty()) { if (!changesToAbandon.isEmpty()) {
validChanges.add(cd); validChanges.add(cd);
} else { } else {
logger logger.atFine().log(
.atFine() "Change data with id \"%s\" does not satisfy the query \"%s\""
.log( + " any more, hence skipping it in clean up",
"Change data with id \"%s\" does not satisfy the query \"%s\"" cd.getId(), query);
+ " any more, hence skipping it in clean up",
cd.getId(), query);
} }
} }
return validChanges; return validChanges;

View File

@@ -467,12 +467,9 @@ public class ChangeInserter implements InsertChangeOp {
.test(ChangePermission.READ) .test(ChangePermission.READ)
&& projectState.statePermitsRead(); && projectState.statePermitsRead();
} catch (PermissionBackendException e) { } catch (PermissionBackendException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Failed to check if account %d can see change %d",
.withCause(e) accountId.get(), notes.getChangeId().get());
.log(
"Failed to check if account %d can see change %d",
accountId.get(), notes.getChangeId().get());
return false; return false;
} }
}) })
@@ -497,10 +494,8 @@ public class ChangeInserter implements InsertChangeOp {
cm.addExtraCC(extraCC); cm.addExtraCC(extraCC);
cm.send(); cm.send();
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Cannot send email for new change %s", change.getId());
.withCause(e)
.log("Cannot send email for new change %s", change.getId());
} }
} }

View File

@@ -501,10 +501,8 @@ public class ChangeJson {
ensureLoaded(Collections.singleton(cd)); ensureLoaded(Collections.singleton(cd));
return Optional.of(format(cd, Optional.empty(), false)); return Optional.of(format(cd, Optional.empty(), false));
} catch (OrmException | RuntimeException e) { } catch (OrmException | RuntimeException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Omitting corrupt change %s from results", cd.getId());
.withCause(e)
.log("Omitting corrupt change %s from results", cd.getId());
return Optional.empty(); return Optional.empty();
} }
}); });

View File

@@ -107,10 +107,8 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
Key key = Key.create(prior, next, useRecursiveMerge); Key key = Key.create(prior, next, useRecursiveMerge);
return new Loader(key, repoManager, project, rw, repoConfig).call(); return new Loader(key, repoManager, project, rw, repoConfig).call();
} catch (IOException e) { } catch (IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot check trivial rebase of new patch set %s in %s", next.name(), project);
.withCause(e)
.log("Cannot check trivial rebase of new patch set %s in %s", next.name(), project);
return ChangeKind.REWORK; return ChangeKind.REWORK;
} }
} }
@@ -346,10 +344,8 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
Key key = Key.create(prior, next, useRecursiveMerge); Key key = Key.create(prior, next, useRecursiveMerge);
return cache.get(key, new Loader(key, repoManager, project, rw, repoConfig)); return cache.get(key, new Loader(key, repoManager, project, rw, repoConfig));
} catch (ExecutionException e) { } catch (ExecutionException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot check trivial rebase of new patch set %s in %s", next.name(), project);
.withCause(e)
.log("Cannot check trivial rebase of new patch set %s in %s", next.name(), project);
return ChangeKind.REWORK; return ChangeKind.REWORK;
} }
} }
@@ -401,12 +397,9 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
} }
} catch (OrmException e) { } catch (OrmException e) {
// Do nothing; assume we have a complex change // Do nothing; assume we have a complex change
logger logger.atWarning().withCause(e).log(
.atWarning() "Unable to get change kind for patchSet %s of change %s",
.withCause(e) patch.getPatchSetId(), change.getId());
.log(
"Unable to get change kind for patchSet %s of change %s",
patch.getPatchSetId(), change.getId());
} }
} }
return kind; return kind;
@@ -431,12 +424,9 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
cache, rw, repo.getConfig(), changeDataFactory.create(db, change), patch); cache, rw, repo.getConfig(), changeDataFactory.create(db, change), patch);
} catch (IOException e) { } catch (IOException e) {
// Do nothing; assume we have a complex change // Do nothing; assume we have a complex change
logger logger.atWarning().withCause(e).log(
.atWarning() "Unable to get change kind for patchSet %s of change %s",
.withCause(e) patch.getPatchSetId(), change.getChangeId());
.log(
"Unable to get change kind for patchSet %s of change %s",
patch.getPatchSetId(), change.getChangeId());
} }
} }
return kind; return kind;

View File

@@ -776,10 +776,8 @@ public class ConsistencyChecker {
} }
private void warn(Throwable t) { private void warn(Throwable t) {
logger logger.atWarning().withCause(t).log(
.atWarning() "Error in consistency check of change %s", notes.getChangeId());
.withCause(t)
.log("Error in consistency check of change %s", notes.getChangeId());
} }
private Result result() { private Result result() {

View File

@@ -204,11 +204,9 @@ public class IncludedInResolver {
} catch (MissingObjectException notHere) { } catch (MissingObjectException notHere) {
// Log the problem with this branch, but keep processing. // Log the problem with this branch, but keep processing.
// //
logger logger.atWarning().log(
.atWarning() "Reference %s in %s points to dangling object %s",
.log( ref.getName(), repo.getDirectory(), ref.getObjectId());
"Reference %s in %s points to dangling object %s",
ref.getName(), repo.getDirectory(), ref.getObjectId());
continue; continue;
} }
commitToRef.put(commit, ref.getName()); commitToRef.put(commit, ref.getName());

View File

@@ -212,12 +212,9 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
} }
}); });
} catch (ExecutionException | UncheckedExecutionException e) { } catch (ExecutionException | UncheckedExecutionException e) {
logger logger.atSevere().withCause(e.getCause()).log(
.atSevere() "Error checking mergeability of %s into %s (%s)",
.withCause(e.getCause()) key.commit.name(), key.into.name(), key.submitType.name());
.log(
"Error checking mergeability of %s into %s (%s)",
key.commit.name(), key.into.name(), key.submitType.name());
return false; return false;
} }
} }

View File

@@ -300,10 +300,8 @@ public class PatchSetInserter implements BatchUpdateOp {
cm.setAccountsToNotify(accountsToNotify); cm.setAccountsToNotify(accountsToNotify);
cm.send(); cm.send();
} catch (Exception err) { } catch (Exception err) {
logger logger.atSevere().withCause(err).log(
.atSevere() "Cannot send email for new patch set on change %s", change.getId());
.withCause(err)
.log("Cannot send email for new patch set on change %s", change.getId());
} }
} }

View File

@@ -68,10 +68,8 @@ public class RebaseUtil {
} catch (RestApiException e) { } catch (RestApiException e) {
return false; return false;
} catch (OrmException | IOException e) { } catch (OrmException | IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Error checking if patch set %s on %s can be rebased", patchSet.getId(), dest);
.withCause(e)
.log("Error checking if patch set %s on %s can be rebased", patchSet.getId(), dest);
return false; return false;
} }
} }

View File

@@ -126,10 +126,8 @@ public class SetAssigneeOp implements BatchUpdateOp {
cm.setFrom(user.get().getAccountId()); cm.setFrom(user.get().getAccountId());
cm.send(); cm.send();
} catch (Exception err) { } catch (Exception err) {
logger logger.atSevere().withCause(err).log(
.atSevere() "Cannot send email to new assignee of change %s", change.getId());
.withCause(err)
.log("Cannot send email to new assignee of change %s", change.getId());
} }
assigneeChanged.fire( assigneeChanged.fire(
change, ctx.getAccount(), oldAssignee != null ? oldAssignee.state() : null, ctx.getWhen()); change, ctx.getAccount(), oldAssignee != null ? oldAssignee.state() : null, ctx.getWhen());

View File

@@ -236,10 +236,8 @@ public class WalkSorter {
RevCommit c = rw.parseCommit(id); RevCommit c = rw.parseCommit(id);
byCommit.put(c, PatchSetData.create(cd, maxPs, c)); byCommit.put(c, PatchSetData.create(cd, maxPs, c));
} catch (MissingObjectException | IncorrectObjectTypeException e) { } catch (MissingObjectException | IncorrectObjectTypeException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "missing commit %s for patch set %s", id.name(), maxPs.getId());
.withCause(e)
.log("missing commit %s for patch set %s", id.name(), maxPs.getId());
} }
} }
return byCommit; return byCommit;

View File

@@ -349,10 +349,8 @@ public class ProjectConfigEntry {
} }
} }
} catch (IOException | ConfigInvalidException e) { } catch (IOException | ConfigInvalidException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Failed to check if plugin config of project %s was updated.", p.get());
.withCause(e)
.log("Failed to check if plugin config of project %s was updated.", p.get());
} }
} }

View File

@@ -161,20 +161,16 @@ public abstract class ScheduleConfig {
} }
if (interval == MISSING_CONFIG) { if (interval == MISSING_CONFIG) {
logger logger.atSevere().log(
.atSevere() "Incomplete schedule configuration for \"%s\" is ignored. Missing value for \"%s\".",
.log( key, key + "." + keyInterval());
"Incomplete schedule configuration for \"%s\" is ignored. Missing value for \"%s\".",
key, key + "." + keyInterval());
return true; return true;
} }
if (initialDelay == MISSING_CONFIG) { if (initialDelay == MISSING_CONFIG) {
logger logger.atSevere().log(
.atSevere() "Incomplete schedule configuration for \"%s\" is ignored. Missing value for \"%s\".",
.log( key, key + "." + keyStartTime());
"Incomplete schedule configuration for \"%s\" is ignored. Missing value for \"%s\".",
key, key + "." + keyStartTime());
return true; return true;
} }

View File

@@ -50,32 +50,27 @@ public class TrackingFootersProvider implements Provider<TrackingFooters> {
if (footers.isEmpty()) { if (footers.isEmpty()) {
configValid = false; configValid = false;
logger logger.atSevere().log(
.atSevere() "Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, FOOTER_TAG);
.log("Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, FOOTER_TAG);
} }
String system = cfg.getString(TRACKING_ID_TAG, name, SYSTEM_TAG); String system = cfg.getString(TRACKING_ID_TAG, name, SYSTEM_TAG);
if (system == null || system.isEmpty()) { if (system == null || system.isEmpty()) {
configValid = false; configValid = false;
logger logger.atSevere().log(
.atSevere() "Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, SYSTEM_TAG);
.log("Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, SYSTEM_TAG);
} else if (system.length() > TrackingId.TRACKING_SYSTEM_MAX_CHAR) { } else if (system.length() > TrackingId.TRACKING_SYSTEM_MAX_CHAR) {
configValid = false; configValid = false;
logger logger.atSevere().log(
.atSevere() "String too long \"%s\" in gerrit.config %s.%s.%s (max %d char)",
.log( system, TRACKING_ID_TAG, name, SYSTEM_TAG, TrackingId.TRACKING_SYSTEM_MAX_CHAR);
"String too long \"%s\" in gerrit.config %s.%s.%s (max %d char)",
system, TRACKING_ID_TAG, name, SYSTEM_TAG, TrackingId.TRACKING_SYSTEM_MAX_CHAR);
} }
String match = cfg.getString(TRACKING_ID_TAG, name, REGEX_TAG); String match = cfg.getString(TRACKING_ID_TAG, name, REGEX_TAG);
if (match == null || match.isEmpty()) { if (match == null || match.isEmpty()) {
configValid = false; configValid = false;
logger logger.atSevere().log(
.atSevere() "Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, REGEX_TAG);
.log("Missing %s.%s.%s in gerrit.config", TRACKING_ID_TAG, name, REGEX_TAG);
} }
if (configValid) { if (configValid) {
@@ -84,11 +79,9 @@ public class TrackingFootersProvider implements Provider<TrackingFooters> {
trackingFooters.add(new TrackingFooter(footer, match, system)); trackingFooters.add(new TrackingFooter(footer, match, system));
} }
} catch (PatternSyntaxException e) { } catch (PatternSyntaxException e) {
logger logger.atSevere().log(
.atSevere() "Invalid pattern \"%s\" in gerrit.config %s.%s.%s: %s",
.log( match, TRACKING_ID_TAG, name, REGEX_TAG, e.getMessage());
"Invalid pattern \"%s\" in gerrit.config %s.%s.%s: %s",
match, TRACKING_ID_TAG, name, REGEX_TAG, e.getMessage());
} }
} }
} }

View File

@@ -202,9 +202,8 @@ public class EventBroker implements EventDispatcher {
.getChange(); .getChange();
return isVisibleTo(change, user); return isVisibleTo(change, user);
} catch (NoSuchChangeException e) { } catch (NoSuchChangeException e) {
logger logger.atFine().log(
.atFine() "Change %s cannot be found, falling back on ref visibility check", cid.id);
.log("Change %s cannot be found, falling back on ref visibility check", cid.id);
} }
} }
return isVisibleTo(refEvent.getBranchNameKey(), user); return isVisibleTo(refEvent.getBranchNameKey(), user);

View File

@@ -157,10 +157,8 @@ public class EventFactory {
try { try {
a.commitMessage = changeDataFactory.create(db, change).commitMessage(); a.commitMessage = changeDataFactory.create(db, change).commitMessage();
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Error while getting full commit message for change %d", a.number);
.withCause(e)
.log("Error while getting full commit message for change %d", a.number);
} }
a.url = getChangeUrl(change); a.url = getChangeUrl(change);
a.owner = asAccountAttribute(change.getOwner()); a.owner = asAccountAttribute(change.getOwner());

View File

@@ -120,24 +120,17 @@ public class EventUtil {
} }
public void logEventListenerError(Object event, Object listener, Exception error) { public void logEventListenerError(Object event, Object listener, Exception error) {
logger logger.atWarning().log(
.atWarning() "Error in event listener %s for event %s: %s",
.log( listener.getClass().getName(), event.getClass().getName(), error.getMessage());
"Error in event listener %s for event %s: %s", logger.atFine().withCause(error).log(
listener.getClass().getName(), event.getClass().getName(), error.getMessage()); "Cause of error in event listener %s:", listener.getClass().getName());
logger
.atFine()
.withCause(error)
.log("Cause of error in event listener %s:", listener.getClass().getName());
} }
public static void logEventListenerError(Object listener, Exception error) { public static void logEventListenerError(Object listener, Exception error) {
logger logger.atWarning().log(
.atWarning() "Error in event listener %s: %s", listener.getClass().getName(), error.getMessage());
.log("Error in event listener %s: %s", listener.getClass().getName(), error.getMessage()); logger.atFine().withCause(error).log(
logger "Cause of error in event listener %s", listener.getClass().getName());
.atFine()
.withCause(error)
.log("Cause of error in event listener %s", listener.getClass().getName());
} }
} }

View File

@@ -130,10 +130,8 @@ public class UiActions {
try { try {
view = e.getProvider().get(); view = e.getProvider().get();
} catch (RuntimeException err) { } catch (RuntimeException err) {
logger logger.atSevere().withCause(err).log(
.atSevere() "error creating view %s.%s", e.getPluginName(), e.getExportName());
.withCause(err)
.log("error creating view %s.%s", e.getPluginName(), e.getExportName());
return null; return null;
} }
@@ -155,10 +153,8 @@ public class UiActions {
try { try {
globalRequired = GlobalPermission.fromAnnotation(e.getPluginName(), view.getClass()); globalRequired = GlobalPermission.fromAnnotation(e.getPluginName(), view.getClass());
} catch (PermissionBackendException err) { } catch (PermissionBackendException err) {
logger logger.atSevere().withCause(err).log(
.atSevere() "exception testing view %s.%s", e.getPluginName(), e.getExportName());
.withCause(err)
.log("exception testing view %s.%s", e.getPluginName(), e.getExportName());
return null; return null;
} }
if (!globalRequired.isEmpty()) { if (!globalRequired.isEmpty()) {

View File

@@ -192,9 +192,8 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
// //
File metaConfigLog = new File(db.getDirectory(), "logs/" + RefNames.REFS_CONFIG); File metaConfigLog = new File(db.getDirectory(), "logs/" + RefNames.REFS_CONFIG);
if (!metaConfigLog.getParentFile().mkdirs() || !metaConfigLog.createNewFile()) { if (!metaConfigLog.getParentFile().mkdirs() || !metaConfigLog.createNewFile()) {
logger logger.atSevere().log(
.atSevere() "Failed to create ref log for %s in repository %s", RefNames.REFS_CONFIG, name);
.log("Failed to create ref log for %s in repository %s", RefNames.REFS_CONFIG, name);
} }
return db; return db;
@@ -247,10 +246,8 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
Integer.MAX_VALUE, Integer.MAX_VALUE,
visitor); visitor);
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Error walking repository tree %s", visitor.startFolder.toAbsolutePath());
.withCause(e)
.log("Error walking repository tree %s", visitor.startFolder.toAbsolutePath());
} }
} }

View File

@@ -180,10 +180,8 @@ public class MergedByPushOp implements BatchUpdateOp {
cm.setPatchSet(patchSet, info); cm.setPatchSet(patchSet, info);
cm.send(); cm.send();
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Cannot send email for submitted patch set %s", psId);
.withCause(e)
.log("Cannot send email for submitted patch set %s", psId);
} }
} }

View File

@@ -214,11 +214,9 @@ public class MultiProgressMonitor {
String.format( String.format(
"(timeout %sms, cancelled)", "(timeout %sms, cancelled)",
TimeUnit.MILLISECONDS.convert(now - deadline, NANOSECONDS)); TimeUnit.MILLISECONDS.convert(now - deadline, NANOSECONDS));
logger logger.atWarning().log(
.atWarning() "MultiProgressMonitor worker killed after %sms: %s",
.log( TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS), detailMessage);
"MultiProgressMonitor worker killed after %sms: %s",
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS), detailMessage);
} }
break; break;
} }

View File

@@ -479,9 +479,8 @@ public class WorkQueue {
} }
} }
} catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { } catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) {
logger logger.atFine().log(
.atFine() "Cannot get a proper name for TrustedListenableFutureTask: %s", e.getMessage());
.log("Cannot get a proper name for TrustedListenableFutureTask: %s", e.getMessage());
} }
return runnable.toString(); return runnable.toString();
} }

View File

@@ -271,12 +271,9 @@ public class AsyncReceiveCommits implements PreReceiveHook {
w.progress.waitFor( w.progress.waitFor(
executor.submit(scopePropagator.wrap(w)), timeoutMillis, TimeUnit.MILLISECONDS); executor.submit(scopePropagator.wrap(w)), timeoutMillis, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) { } catch (ExecutionException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Error in ReceiveCommits while processing changes for project %s",
.withCause(e) projectState.getName());
.log(
"Error in ReceiveCommits while processing changes for project %s",
projectState.getName());
rp.sendError("internal error while processing changes"); rp.sendError("internal error while processing changes");
// ReceiveCommits has tried its best to catch errors, so anything at this // ReceiveCommits has tried its best to catch errors, so anything at this
// point is very bad. // point is very bad.

View File

@@ -1254,11 +1254,10 @@ class ReceiveCommits {
String topic; String topic;
@Option( @Option(
name = "--draft", name = "--draft",
usage = usage =
"Will be removed. Before that, this option will be mapped to '--private'" "Will be removed. Before that, this option will be mapped to '--private'"
+ "for new changes and '--edit' for existing changes" + "for new changes and '--edit' for existing changes")
)
boolean draft; boolean draft;
boolean publish; boolean publish;
@@ -1270,20 +1269,18 @@ class ReceiveCommits {
boolean removePrivate; boolean removePrivate;
@Option( @Option(
name = "--wip", name = "--wip",
aliases = {"-work-in-progress"}, aliases = {"-work-in-progress"},
usage = "mark change as work in progress" usage = "mark change as work in progress")
)
boolean workInProgress; boolean workInProgress;
@Option(name = "--ready", usage = "mark change as ready") @Option(name = "--ready", usage = "mark change as ready")
boolean ready; boolean ready;
@Option( @Option(
name = "--edit", name = "--edit",
aliases = {"-e"}, aliases = {"-e"},
usage = "upload as change edit" usage = "upload as change edit")
)
boolean edit; boolean edit;
@Option(name = "--submit", usage = "immediately submit the change") @Option(name = "--submit", usage = "immediately submit the change")
@@ -1296,19 +1293,17 @@ class ReceiveCommits {
private boolean publishComments; private boolean publishComments;
@Option( @Option(
name = "--no-publish-comments", name = "--no-publish-comments",
aliases = {"--np"}, aliases = {"--np"},
usage = "do not publish draft comments" usage = "do not publish draft comments")
)
private boolean noPublishComments; private boolean noPublishComments;
@Option( @Option(
name = "--notify", name = "--notify",
usage = usage =
"Notify handling that defines to whom email notifications " "Notify handling that defines to whom email notifications "
+ "should be sent. Allowed values are NONE, OWNER, " + "should be sent. Allowed values are NONE, OWNER, "
+ "OWNER_REVIEWERS, ALL. If not set, the default is ALL." + "OWNER_REVIEWERS, ALL. If not set, the default is ALL.")
)
private NotifyHandling notify; private NotifyHandling notify;
@Option(name = "--notify-to", metaVar = "USER", usage = "user that should be notified") @Option(name = "--notify-to", metaVar = "USER", usage = "user that should be notified")
@@ -1321,11 +1316,10 @@ class ReceiveCommits {
List<Account.Id> bccs = new ArrayList<>(); List<Account.Id> bccs = new ArrayList<>();
@Option( @Option(
name = "--reviewer", name = "--reviewer",
aliases = {"-r"}, aliases = {"-r"},
metaVar = "EMAIL", metaVar = "EMAIL",
usage = "add reviewer to changes" usage = "add reviewer to changes")
)
void reviewer(Account.Id id) { void reviewer(Account.Id id) {
reviewer.add(id); reviewer.add(id);
} }
@@ -1336,11 +1330,10 @@ class ReceiveCommits {
} }
@Option( @Option(
name = "--label", name = "--label",
aliases = {"-l"}, aliases = {"-l"},
metaVar = "LABEL+VALUE", metaVar = "LABEL+VALUE",
usage = "label(s) to assign (defaults to +1 if no value provided" usage = "label(s) to assign (defaults to +1 if no value provided")
)
void addLabel(String token) throws CmdLineException { void addLabel(String token) throws CmdLineException {
LabelVote v = LabelVote.parse(token); LabelVote v = LabelVote.parse(token);
try { try {
@@ -1353,11 +1346,10 @@ class ReceiveCommits {
} }
@Option( @Option(
name = "--message", name = "--message",
aliases = {"-m"}, aliases = {"-m"},
metaVar = "MESSAGE", metaVar = "MESSAGE",
usage = "Comment message to apply to the review" usage = "Comment message to apply to the review")
)
void addMessage(String token) { void addMessage(String token) {
// Many characters have special meaning in the context of a git ref. // Many characters have special meaning in the context of a git ref.
// //
@@ -1375,11 +1367,10 @@ class ReceiveCommits {
} }
@Option( @Option(
name = "--hashtag", name = "--hashtag",
aliases = {"-t"}, aliases = {"-t"},
metaVar = "HASHTAG", metaVar = "HASHTAG",
usage = "add hashtag to changes" usage = "add hashtag to changes")
)
void addHashtag(String token) throws CmdLineException { void addHashtag(String token) throws CmdLineException {
if (!notesMigration.readChanges()) { if (!notesMigration.readChanges()) {
throw clp.reject("cannot add hashtags; noteDb is disabled"); throw clp.reject("cannot add hashtags; noteDb is disabled");
@@ -2706,10 +2697,8 @@ class ReceiveCommits {
try { try {
projectCache.evict(project); projectCache.evict(project);
} catch (IOException e) { } catch (IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot evict from project cache, name key: %s", project.getName());
.withCause(e)
.log("Cannot evict from project cache, name key: %s", project.getName());
} }
ProjectState ps = projectCache.get(project.getNameKey()); ProjectState ps = projectCache.get(project.getNameKey());
try { try {

View File

@@ -515,10 +515,8 @@ public class ReplaceOp implements BatchUpdateOp {
cm.addExtraCC(recipients.getCcOnly()); cm.addExtraCC(recipients.getCcOnly());
cm.send(); cm.send();
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Cannot send email for new patch set %s", newPatchSet.getId());
.withCause(e)
.log("Cannot send email for new patch set %s", newPatchSet.getId());
} }
} }

View File

@@ -226,10 +226,8 @@ public class CommitValidators {
messages.addAll(commitValidator.onCommitReceived(receiveEvent)); messages.addAll(commitValidator.onCommitReceived(receiveEvent));
} }
} catch (CommitValidationException e) { } catch (CommitValidationException e) {
logger logger.atFine().withCause(e).log(
.atFine() "CommitValidationException occurred: %s", e.getFullMessage());
.withCause(e)
.log("CommitValidationException occurred: %s", e.getFullMessage());
// Keep the old messages (and their order) in case of an exception // Keep the old messages (and their order) in case of an exception
messages.addAll(e.getMessages()); messages.addAll(e.getMessages());
throw new CommitValidationException(e.getMessage(), messages); throw new CommitValidationException(e.getMessage(), messages);
@@ -445,14 +443,11 @@ public class CommitValidators {
throw new ConfigInvalidException("invalid project configuration"); throw new ConfigInvalidException("invalid project configuration");
} }
} catch (ConfigInvalidException | IOException e) { } catch (ConfigInvalidException | IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "User %s tried to push an invalid project configuration %s for project %s",
.withCause(e) user.getLoggableName(),
.log( receiveEvent.command.getNewId().name(),
"User %s tried to push an invalid project configuration %s for project %s", receiveEvent.project.getName());
user.getLoggableName(),
receiveEvent.command.getNewId().name(),
receiveEvent.project.getName());
throw new CommitValidationException("invalid project configuration", messages); throw new CommitValidationException("invalid project configuration", messages);
} }
} }

View File

@@ -183,11 +183,9 @@ public class AuditLogReader {
} }
private static void logInvalid(AccountGroup.UUID uuid, RevCommit c, FooterLine line) { private static void logInvalid(AccountGroup.UUID uuid, RevCommit c, FooterLine line) {
logger logger.atFine().log(
.atFine() "Invalid footer line in commit %s while parsing audit log for group %s: %s",
.log( c.name(), uuid, line);
"Invalid footer line in commit %s while parsing audit log for group %s: %s",
c.name(), uuid, line);
} }
private ImmutableList<ParsedCommit> parseCommits(Repository repo, AccountGroup.UUID uuid) private ImmutableList<ParsedCommit> parseCommits(Repository repo, AccountGroup.UUID uuid)

View File

@@ -127,12 +127,9 @@ class RenameGroupOp extends DefaultQueueOp {
projectCache.evict(config.getProject()); projectCache.evict(config.getProject());
success = true; success = true;
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Could not commit rename of group %s to %s in %s",
.withCause(e) oldName, newName, md.getProjectName().get());
.log(
"Could not commit rename of group %s to %s in %s",
oldName, newName, md.getProjectName().get());
try { try {
Thread.sleep(25 /* milliseconds */); Thread.sleep(25 /* milliseconds */);
} catch (InterruptedException wakeUp) { } catch (InterruptedException wakeUp) {
@@ -143,11 +140,8 @@ class RenameGroupOp extends DefaultQueueOp {
if (!success) { if (!success) {
if (tryingAgain) { if (tryingAgain) {
logger logger.atWarning().log(
.atWarning() "Could not rename group %s to %s in %s", oldName, newName, md.getProjectName().get());
.log(
"Could not rename group %s to %s in %s",
oldName, newName, md.getProjectName().get());
} else { } else {
retryOn.add(md.getProjectName()); retryOn.add(md.getProjectName());
} }

View File

@@ -63,10 +63,8 @@ public class OnlineReindexer<K, V, I extends Index<K, V>> {
reindex(); reindex();
ok = true; ok = true;
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Online reindex of %s schema version %s failed", name, version(index));
.withCause(e)
.log("Online reindex of %s schema version %s failed", name, version(index));
} finally { } finally {
running.set(false); running.set(false);
if (!ok) { if (!ok) {
@@ -105,23 +103,19 @@ public class OnlineReindexer<K, V, I extends Index<K, V>> {
"not an active write schema version: %s %s", "not an active write schema version: %s %s",
name, name,
newVersion); newVersion);
logger logger.atInfo().log(
.atInfo() "Starting online reindex of %s from schema version %s to %s",
.log( name, version(indexes.getSearchIndex()), version(index));
"Starting online reindex of %s from schema version %s to %s",
name, version(indexes.getSearchIndex()), version(index));
if (oldVersion != newVersion) { if (oldVersion != newVersion) {
index.deleteAll(); index.deleteAll();
} }
SiteIndexer.Result result = batchIndexer.indexAll(index); SiteIndexer.Result result = batchIndexer.indexAll(index);
if (!result.success()) { if (!result.success()) {
logger logger.atSevere().log(
.atSevere() "Online reindex of %s schema version %s failed. Successfully"
.log( + " indexed %s, failed to index %s",
"Online reindex of %s schema version %s failed. Successfully" name, version(index), result.doneCount(), result.failedCount());
+ " indexed %s, failed to index %s",
name, version(index), result.doneCount(), result.failedCount());
return; return;
} }
logger.atInfo().log("Reindex %s to version %s complete", name, version(index)); logger.atInfo().log("Reindex %s to version %s complete", name, version(index));

View File

@@ -186,11 +186,9 @@ public class AllChangesIndexer extends SiteIndexer<Change.Id, ChangeData, Change
int nTotal = nFailed + nDone; int nTotal = nFailed + nDone;
double pctFailed = ((double) nFailed) / nTotal * 100; double pctFailed = ((double) nFailed) / nTotal * 100;
if (pctFailed > 10) { if (pctFailed > 10) {
logger logger.atSevere().log(
.atSevere() "Failed %s/%s changes (%s%%); not marking new index as ready",
.log( nFailed, nTotal, Math.round(pctFailed));
"Failed %s/%s changes (%s%%); not marking new index as ready",
nFailed, nTotal, Math.round(pctFailed));
ok.set(false); ok.set(false);
} }
return new Result(sw, ok.get(), nDone, nFailed); return new Result(sw, ok.get(), nDone, nFailed);

View File

@@ -266,9 +266,8 @@ public class ChangeField {
int i = v.indexOf(','); int i = v.indexOf(',');
if (i < 0) { if (i < 0) {
logger logger.atWarning().log(
.atWarning() "Invalid value for reviewer field from change %s: %s", changeId.get(), v);
.log("Invalid value for reviewer field from change %s: %s", changeId.get(), v);
continue; continue;
} }
@@ -286,31 +285,23 @@ public class ChangeField {
com.google.common.base.Optional<ReviewerStateInternal> reviewerState = com.google.common.base.Optional<ReviewerStateInternal> reviewerState =
Enums.getIfPresent(ReviewerStateInternal.class, v.substring(0, i)); Enums.getIfPresent(ReviewerStateInternal.class, v.substring(0, i));
if (!reviewerState.isPresent()) { if (!reviewerState.isPresent()) {
logger logger.atWarning().log(
.atWarning() "Failed to parse reviewer state of reviewer field from change %s: %s",
.log( changeId.get(), v);
"Failed to parse reviewer state of reviewer field from change %s: %s",
changeId.get(), v);
continue; continue;
} }
Optional<Account.Id> accountId = Account.Id.tryParse(v.substring(i + 1, i2)); Optional<Account.Id> accountId = Account.Id.tryParse(v.substring(i + 1, i2));
if (!accountId.isPresent()) { if (!accountId.isPresent()) {
logger logger.atWarning().log(
.atWarning() "Failed to parse account ID of reviewer field from change %s: %s", changeId.get(), v);
.log(
"Failed to parse account ID of reviewer field from change %s: %s",
changeId.get(), v);
continue; continue;
} }
Long l = Longs.tryParse(v.substring(i2 + 1, v.length())); Long l = Longs.tryParse(v.substring(i2 + 1, v.length()));
if (l == null) { if (l == null) {
logger logger.atWarning().log(
.atWarning() "Failed to parse timestamp of reviewer field from change %s: %s", changeId.get(), v);
.log(
"Failed to parse timestamp of reviewer field from change %s: %s",
changeId.get(), v);
continue; continue;
} }
Timestamp timestamp = new Timestamp(l); Timestamp timestamp = new Timestamp(l);
@@ -326,9 +317,8 @@ public class ChangeField {
for (String v : values) { for (String v : values) {
int i = v.indexOf(','); int i = v.indexOf(',');
if (i < 0) { if (i < 0) {
logger logger.atWarning().log(
.atWarning() "Invalid value for reviewer by email field from change %s: %s", changeId.get(), v);
.log("Invalid value for reviewer by email field from change %s: %s", changeId.get(), v);
continue; continue;
} }
@@ -347,31 +337,25 @@ public class ChangeField {
com.google.common.base.Optional<ReviewerStateInternal> reviewerState = com.google.common.base.Optional<ReviewerStateInternal> reviewerState =
Enums.getIfPresent(ReviewerStateInternal.class, v.substring(0, i)); Enums.getIfPresent(ReviewerStateInternal.class, v.substring(0, i));
if (!reviewerState.isPresent()) { if (!reviewerState.isPresent()) {
logger logger.atWarning().log(
.atWarning() "Failed to parse reviewer state of reviewer by email field from change %s: %s",
.log( changeId.get(), v);
"Failed to parse reviewer state of reviewer by email field from change %s: %s",
changeId.get(), v);
continue; continue;
} }
Address address = Address.tryParse(v.substring(i + 1, i2)); Address address = Address.tryParse(v.substring(i + 1, i2));
if (address == null) { if (address == null) {
logger logger.atWarning().log(
.atWarning() "Failed to parse address of reviewer by email field from change %s: %s",
.log( changeId.get(), v);
"Failed to parse address of reviewer by email field from change %s: %s",
changeId.get(), v);
continue; continue;
} }
Long l = Longs.tryParse(v.substring(i2 + 1, v.length())); Long l = Longs.tryParse(v.substring(i2 + 1, v.length()));
if (l == null) { if (l == null) {
logger logger.atWarning().log(
.atWarning() "Failed to parse timestamp of reviewer by email field from change %s: %s",
.log( changeId.get(), v);
"Failed to parse timestamp of reviewer by email field from change %s: %s",
changeId.get(), v);
continue; continue;
} }
Timestamp timestamp = new Timestamp(l); Timestamp timestamp = new Timestamp(l);

View File

@@ -441,11 +441,9 @@ public class ChangeIndexer {
if (!isCausedByRepositoryNotFoundException(e)) { if (!isCausedByRepositoryNotFoundException(e)) {
throw e; throw e;
} }
logger logger.atFine().log(
.atFine() "Change %s belongs to deleted project %s, aborting reindexing the change.",
.log( id.get(), project.get());
"Change %s belongs to deleted project %s, aborting reindexing the change.",
id.get(), project.get());
} }
return false; return false;
} }

View File

@@ -30,11 +30,8 @@ public class AutoReplyMailFilter implements MailFilter {
String prec = header.substring(MailHeader.PRECEDENCE.fieldWithDelimiter().length()).trim(); String prec = header.substring(MailHeader.PRECEDENCE.fieldWithDelimiter().length()).trim();
if (prec.equals("list") || prec.equals("junk") || prec.equals("bulk")) { if (prec.equals("list") || prec.equals("junk") || prec.equals("bulk")) {
logger logger.atSevere().log(
.atSevere() "Message %s has a Precedence header. Will ignore and delete message.", message.id());
.log(
"Message %s has a Precedence header. Will ignore and delete message.",
message.id());
return false; return false;
} }
@@ -43,11 +40,9 @@ public class AutoReplyMailFilter implements MailFilter {
header.substring(MailHeader.AUTO_SUBMITTED.fieldWithDelimiter().length()).trim(); header.substring(MailHeader.AUTO_SUBMITTED.fieldWithDelimiter().length()).trim();
if (!autoSubmitted.equals("no")) { if (!autoSubmitted.equals("no")) {
logger logger.atSevere().log(
.atSevere() "Message %s has an Auto-Submitted header. Will ignore and delete message.",
.log( message.id());
"Message %s has an Auto-Submitted header. Will ignore and delete message.",
message.id());
return false; return false;
} }
} }

View File

@@ -108,9 +108,8 @@ public class ImapMailReceiver extends MailReceiver {
if (imap.store(i + ":" + i, "+FLAGS", "(\\Deleted)")) { if (imap.store(i + ":" + i, "+FLAGS", "(\\Deleted)")) {
pendingDeletion.remove(mailMessage.id()); pendingDeletion.remove(mailMessage.id());
} else { } else {
logger logger.atSevere().log(
.atSevere() "Could not mark mail message as deleted: %s", mailMessage.id());
.log("Could not mark mail message as deleted: %s", mailMessage.id());
} }
} else { } else {
mailMessages.add(mailMessage); mailMessages.add(mailMessage);

View File

@@ -46,10 +46,8 @@ public class MailHeaderParser {
try { try {
metadata.timestamp = Timestamp.from(MailUtil.rfcDateformatter.parse(ts, Instant::from)); metadata.timestamp = Timestamp.from(MailUtil.rfcDateformatter.parse(ts, Instant::from));
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Mail: Error while parsing timestamp from header of message %s", m.id());
.withCause(e)
.log("Mail: Error while parsing timestamp from header of message %s", m.id());
} }
} else if (header.startsWith(MailHeader.MESSAGE_TYPE.fieldWithDelimiter())) { } else if (header.startsWith(MailHeader.MESSAGE_TYPE.fieldWithDelimiter())) {
metadata.messageType = metadata.messageType =
@@ -95,10 +93,8 @@ public class MailHeaderParser {
try { try {
metadata.timestamp = Timestamp.from(MailUtil.rfcDateformatter.parse(ts, Instant::from)); metadata.timestamp = Timestamp.from(MailUtil.rfcDateformatter.parse(ts, Instant::from));
} catch (DateTimeParseException e) { } catch (DateTimeParseException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Mail: Error while parsing timestamp from footer of message %s", m.id());
.withCause(e)
.log("Mail: Error while parsing timestamp from footer of message %s", m.id());
} }
} else if (metadata.messageType == null && line.contains(MailHeader.MESSAGE_TYPE.getName())) { } else if (metadata.messageType == null && line.contains(MailHeader.MESSAGE_TYPE.getName())) {
metadata.messageType = extractFooter(MailHeader.MESSAGE_TYPE.withDelimiter(), line); metadata.messageType = extractFooter(MailHeader.MESSAGE_TYPE.withDelimiter(), line);

View File

@@ -144,11 +144,9 @@ public class MailProcessor {
throws OrmException, UpdateException, RestApiException, IOException { throws OrmException, UpdateException, RestApiException, IOException {
for (DynamicMap.Entry<MailFilter> filter : mailFilters) { for (DynamicMap.Entry<MailFilter> filter : mailFilters) {
if (!filter.getProvider().get().shouldProcessMessage(message)) { if (!filter.getProvider().get().shouldProcessMessage(message)) {
logger logger.atWarning().log(
.atWarning() "Message %s filtered by plugin %s %s. Will delete message.",
.log( message.id(), filter.getPluginName(), filter.getExportName());
"Message %s filtered by plugin %s %s. Will delete message.",
message.id(), filter.getPluginName(), filter.getExportName());
return; return;
} }
} }
@@ -156,11 +154,9 @@ public class MailProcessor {
MailMetadata metadata = MailHeaderParser.parse(message); MailMetadata metadata = MailHeaderParser.parse(message);
if (!metadata.hasRequiredFields()) { if (!metadata.hasRequiredFields()) {
logger logger.atSevere().log(
.atSevere() "Message %s is missing required metadata, have %s. Will delete message.",
.log( message.id(), metadata);
"Message %s is missing required metadata, have %s. Will delete message.",
message.id(), metadata);
sendRejectionEmail(message, InboundEmailRejectionSender.Error.PARSING_ERROR); sendRejectionEmail(message, InboundEmailRejectionSender.Error.PARSING_ERROR);
return; return;
} }
@@ -168,12 +164,10 @@ public class MailProcessor {
Set<Account.Id> accountIds = emails.getAccountFor(metadata.author); Set<Account.Id> accountIds = emails.getAccountFor(metadata.author);
if (accountIds.size() != 1) { if (accountIds.size() != 1) {
logger logger.atSevere().log(
.atSevere() "Address %s could not be matched to a unique account. It was matched to %s."
.log( + " Will delete message.",
"Address %s could not be matched to a unique account. It was matched to %s." metadata.author, accountIds);
+ " Will delete message.",
metadata.author, accountIds);
// We don't want to send an email if no accounts are linked to it. // We don't want to send an email if no accounts are linked to it.
if (accountIds.size() > 1) { if (accountIds.size() > 1) {
@@ -213,13 +207,11 @@ public class MailProcessor {
List<ChangeData> changeDataList = List<ChangeData> changeDataList =
queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber)); queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
if (changeDataList.size() != 1) { if (changeDataList.size() != 1) {
logger logger.atSevere().log(
.atSevere() "Message %s references unique change %s,"
.log( + " but there are %d matching changes in the index."
"Message %s references unique change %s," + " Will delete message.",
+ " but there are %d matching changes in the index." message.id(), metadata.changeNumber, changeDataList.size());
+ " Will delete message.",
message.id(), metadata.changeNumber, changeDataList.size());
sendRejectionEmail(message, InboundEmailRejectionSender.Error.INTERNAL_EXCEPTION); sendRejectionEmail(message, InboundEmailRejectionSender.Error.INTERNAL_EXCEPTION);
return; return;
@@ -249,9 +241,8 @@ public class MailProcessor {
} }
if (parsedComments.isEmpty()) { if (parsedComments.isEmpty()) {
logger logger.atWarning().log(
.atWarning() "Could not parse any comments from %s. Will delete message.", message.id());
.log("Could not parse any comments from %s. Will delete message.", message.id());
sendRejectionEmail(message, InboundEmailRejectionSender.Error.PARSING_ERROR); sendRejectionEmail(message, InboundEmailRejectionSender.Error.PARSING_ERROR);
return; return;
} }

View File

@@ -140,10 +140,8 @@ public abstract class MailReceiver implements LifecycleListener {
mailProcessor.process(m); mailProcessor.process(m);
requestDeletion(m.id()); requestDeletion(m.id());
} catch (RestApiException | UpdateException e) { } catch (RestApiException | UpdateException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Mail: Can't process message %s . Won't delete.", m.id());
.withCause(e)
.log("Mail: Can't process message %s . Won't delete.", m.id());
} }
}); });
} else { } else {

View File

@@ -226,12 +226,9 @@ public class CommentSender extends ReplyToChangeSender {
try { try {
currentGroup.fileData = new PatchFile(repo, patchList, c.key.filename); currentGroup.fileData = new PatchFile(repo, patchList, c.key.filename);
} catch (IOException e) { } catch (IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot load %s from %s in %s",
.withCause(e) c.key.filename, patchList.getNewId().name(), projectState.getName());
.log(
"Cannot load %s from %s in %s",
c.key.filename, patchList.getNewId().name(), projectState.getName());
currentGroup.fileData = null; currentGroup.fileData = null;
} }
} }

View File

@@ -101,11 +101,9 @@ public class ProjectWatch {
try { try {
add(matching, nc); add(matching, nc);
} catch (QueryParseException e) { } catch (QueryParseException e) {
logger logger.atWarning().log(
.atWarning() "Project %s has invalid notify %s filter \"%s\": %s",
.log( state.getName(), nc.getName(), nc.getFilter(), e.getMessage());
"Project %s has invalid notify %s filter \"%s\": %s",
state.getName(), nc.getName(), nc.getFilter(), e.getMessage());
} }
} }
} }

View File

@@ -364,19 +364,16 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
if (defaultStorage == PrimaryStorage.REVIEW_DB) { if (defaultStorage == PrimaryStorage.REVIEW_DB) {
// If changes should exist in ReviewDb, it's worth warning about a meta ref with // If changes should exist in ReviewDb, it's worth warning about a meta ref with
// no corresponding ReviewDb data. // no corresponding ReviewDb data.
logger logger.atWarning().log(
.atWarning() "skipping change %s found in project %s but not in ReviewDb", id, project);
.log("skipping change %s found in project %s but not in ReviewDb", id, project);
return null; return null;
} }
// TODO(dborowitz): See discussion in NoteDbBatchUpdate#newChangeContext. // TODO(dborowitz): See discussion in NoteDbBatchUpdate#newChangeContext.
change = ChangeNotes.Factory.newNoteDbOnlyChange(project, id); change = ChangeNotes.Factory.newNoteDbOnlyChange(project, id);
} else if (!change.getProject().equals(project)) { } else if (!change.getProject().equals(project)) {
logger logger.atSevere().log(
.atSevere() "skipping change %s found in project %s because ReviewDb change has project %s",
.log( id, project, change.getProject());
"skipping change %s found in project %s because ReviewDb change has project %s",
id, project, change.getProject());
return null; return null;
} }
logger.atFine().log("adding change %s found in project %s", id, project); logger.atFine().log("adding change %s found in project %s", id, project);
@@ -779,13 +776,11 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
} catch (OrmException e) { } catch (OrmException e) {
throw new IOException(e); throw new IOException(e);
} finally { } finally {
logger logger.atFine().log(
.atFine() "Rebuilt change %s in project %s in %s ms",
.log( getChangeId(),
"Rebuilt change %s in project %s in %s ms", getProjectName(),
getChangeId(), TimeUnit.MILLISECONDS.convert(timer.stop(), TimeUnit.NANOSECONDS));
getProjectName(),
TimeUnit.MILLISECONDS.convert(timer.stop(), TimeUnit.NANOSECONDS));
} }
} }
} }

View File

@@ -1091,9 +1091,8 @@ class ChangeNotesParser {
approvals.values(), PatchSetApproval::getPatchSetId, missing); approvals.values(), PatchSetApproval::getPatchSetId, missing);
if (!missing.isEmpty()) { if (!missing.isEmpty()) {
logger logger.atWarning().log(
.atWarning() "ignoring %s additional entities due to missing patch sets: %s", pruned, missing);
.log("ignoring %s additional entities due to missing patch sets: %s", pruned, missing);
} }
} }

View File

@@ -224,9 +224,8 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
repo.scanForRepoChanges(); repo.scanForRepoChanges();
} catch (OrmException | IOException e) { } catch (OrmException | IOException e) {
// See ChangeNotes#rebuildAndOpen. // See ChangeNotes#rebuildAndOpen.
logger logger.atFine().log(
.atFine() "Rebuilding change %s via drafts failed: %s", getChangeId(), e.getMessage());
.log("Rebuilding change %s via drafts failed: %s", getChangeId(), e.getMessage());
args.metrics.autoRebuildFailureCount.increment(CHANGES); args.metrics.autoRebuildFailureCount.increment(CHANGES);
checkNotNull(r.staged()); checkNotNull(r.staged());
return LoadHandle.create( return LoadHandle.create(
@@ -239,13 +238,11 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
} catch (OrmException e) { } catch (OrmException e) {
throw new IOException(e); throw new IOException(e);
} finally { } finally {
logger logger.atFine().log(
.atFine() "Rebuilt change %s in %s in %s ms via drafts",
.log( getChangeId(),
"Rebuilt change %s in %s in %s ms via drafts", change != null ? "project " + change.getProject() : "unknown project",
getChangeId(), TimeUnit.MILLISECONDS.convert(timer.stop(), TimeUnit.NANOSECONDS));
change != null ? "project " + change.getProject() : "unknown project",
TimeUnit.MILLISECONDS.convert(timer.stop(), TimeUnit.NANOSECONDS));
} }
} }

View File

@@ -276,9 +276,8 @@ public class PrimaryStorageMigrator {
// the primary storage to NoteDb. // the primary storage to NoteDb.
setPrimaryStorageNoteDb(id, rebuiltState); setPrimaryStorageNoteDb(id, rebuiltState);
logger logger.atFine().log(
.atFine() "Migrated change %s to NoteDb primary in %sms", id, sw.elapsed(MILLISECONDS));
.log("Migrated change %s to NoteDb primary in %sms", id, sw.elapsed(MILLISECONDS));
} }
private Change setReadOnlyInReviewDb(Change.Id id) throws OrmException { private Change setReadOnlyInReviewDb(Change.Id id) throws OrmException {
@@ -414,9 +413,8 @@ public class PrimaryStorageMigrator {
rebuilder.rebuildReviewDb(db(), project, id); rebuilder.rebuildReviewDb(db(), project, id);
setPrimaryStorageReviewDb(id, newMetaId); setPrimaryStorageReviewDb(id, newMetaId);
releaseReadOnlyLeaseInNoteDb(project, id); releaseReadOnlyLeaseInNoteDb(project, id);
logger logger.atFine().log(
.atFine() "Migrated change %s to ReviewDb primary in %sms", id, sw.elapsed(MILLISECONDS));
.log("Migrated change %s to ReviewDb primary in %sms", id, sw.elapsed(MILLISECONDS));
} }
private ObjectId setReadOnlyInNoteDb(Project.NameKey project, Change.Id id) private ObjectId setReadOnlyInNoteDb(Project.NameKey project, Change.Id id)

View File

@@ -66,11 +66,9 @@ class CommentEvent extends Event {
try { try {
setCommentRevId(c, cache, change, ps); setCommentRevId(c, cache, change, ps);
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
logger logger.atWarning().log(
.atWarning() "Unable to determine parent commit of patch set %s (%s); omitting inline comment %s",
.log( ps.getId(), ps.getRevision(), c);
"Unable to determine parent commit of patch set %s (%s); omitting inline comment %s",
ps.getId(), ps.getRevision(), c);
return; return;
} }
} }

View File

@@ -64,12 +64,10 @@ class DraftCommentEvent extends Event {
try { try {
setCommentRevId(c, cache, change, ps); setCommentRevId(c, cache, change, ps);
} catch (PatchListNotAvailableException e) { } catch (PatchListNotAvailableException e) {
logger logger.atWarning().log(
.atWarning() "Unable to determine parent commit of patch set %s (%s);"
.log( + " omitting draft inline comment %s",
"Unable to determine parent commit of patch set %s (%s);" ps.getId(), ps.getRevision(), c);
+ " omitting draft inline comment %s",
ps.getId(), ps.getRevision(), c);
return; return;
} }
} }

View File

@@ -614,23 +614,18 @@ public class NoteDbMigrator implements AutoCloseable {
} catch (NoNoteDbStateException e) { } catch (NoNoteDbStateException e) {
if (canSkipPrimaryStorageMigration( if (canSkipPrimaryStorageMigration(
ctx.getReviewDbProvider().get(), id)) { ctx.getReviewDbProvider().get(), id)) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Change %s previously failed to rebuild;"
.withCause(e) + " skipping primary storage migration",
.log( id);
"Change %s previously failed to rebuild;"
+ " skipping primary storage migration",
id);
} else { } else {
throw e; throw e;
} }
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Error migrating primary storage for %s", id);
.withCause(e)
.log("Error migrating primary storage for %s", id);
return false; return false;
} }
})) }))
@@ -638,11 +633,9 @@ public class NoteDbMigrator implements AutoCloseable {
boolean ok = futuresToBoolean(futures, "Error migrating primary storage"); boolean ok = futuresToBoolean(futures, "Error migrating primary storage");
double t = sw.elapsed(TimeUnit.MILLISECONDS) / 1000d; double t = sw.elapsed(TimeUnit.MILLISECONDS) / 1000d;
logger logger.atInfo().log(
.atInfo() "Migrated primary storage of %d changes in %.01fs (%.01f/s)\n",
.log( allChanges.size(), t, allChanges.size() / t);
"Migrated primary storage of %d changes in %.01fs (%.01f/s)\n",
allChanges.size(), t, allChanges.size() / t);
if (!ok) { if (!ok) {
throw new MigrationException("Migrating primary storage for some changes failed, see log"); throw new MigrationException("Migrating primary storage for some changes failed, see log");
} }
@@ -678,10 +671,8 @@ public class NoteDbMigrator implements AutoCloseable {
try { try {
return Iterables.isEmpty(unwrapDb(db).patchSets().byChange(id)); return Iterables.isEmpty(unwrapDb(db).patchSets().byChange(id));
} catch (Exception e) { } catch (Exception e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Error checking if change %s can be skipped, assuming no", id);
.withCause(e)
.log("Error checking if change %s can be skipped, assuming no", id);
return false; return false;
} }
} }
@@ -696,10 +687,8 @@ public class NoteDbMigrator implements AutoCloseable {
noteDbConfig.load(); noteDbConfig.load();
return NotesMigrationState.forConfig(noteDbConfig); return NotesMigrationState.forConfig(noteDbConfig);
} catch (ConfigInvalidException | IllegalArgumentException e) { } catch (ConfigInvalidException | IllegalArgumentException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "error reading NoteDb migration options from %s", noteDbConfig.getFile());
.withCause(e)
.log("error reading NoteDb migration options from %s", noteDbConfig.getFile());
return Optional.empty(); return Optional.empty();
} }
} }
@@ -793,11 +782,9 @@ public class NoteDbMigrator implements AutoCloseable {
boolean ok = futuresToBoolean(futures, "Error rebuilding projects"); boolean ok = futuresToBoolean(futures, "Error rebuilding projects");
double t = sw.elapsed(TimeUnit.MILLISECONDS) / 1000d; double t = sw.elapsed(TimeUnit.MILLISECONDS) / 1000d;
logger logger.atInfo().log(
.atInfo() "Rebuilt %d changes in %.01fs (%.01f/s)\n",
.log( changesByProject.size(), t, changesByProject.size() / t);
"Rebuilt %d changes in %.01fs (%.01f/s)\n",
changesByProject.size(), t, changesByProject.size() / t);
if (!ok) { if (!ok) {
throw new MigrationException("Rebuilding some changes failed, see log"); throw new MigrationException("Rebuilding some changes failed, see log");
} }
@@ -907,12 +894,10 @@ public class NoteDbMigrator implements AutoCloseable {
} catch (NoPatchSetsException e) { } catch (NoPatchSetsException e) {
logger.atWarning().log(e.getMessage()); logger.atWarning().log(e.getMessage());
} catch (ConflictingUpdateException ex) { } catch (ConflictingUpdateException ex) {
logger logger.atWarning().log(
.atWarning() "Rebuilding detected a conflicting ReviewDb update for change %s;"
.log( + " will be auto-rebuilt at runtime",
"Rebuilding detected a conflicting ReviewDb update for change %s;" changeId);
+ " will be auto-rebuilt at runtime",
changeId);
} catch (Throwable t) { } catch (Throwable t) {
logger.atSevere().withCause(t).log("Failed to rebuild change %s", changeId); logger.atSevere().withCause(t).log("Failed to rebuild change %s", changeId);
ok = false; ok = false;
@@ -932,12 +917,10 @@ public class NoteDbMigrator implements AutoCloseable {
// to specify the repo name in the task text. // to specify the repo name in the task text.
pm.update(toSave); pm.update(toSave);
} catch (LockFailureException e) { } catch (LockFailureException e) {
logger logger.atWarning().log(
.atWarning() "Rebuilding detected a conflicting NoteDb update for the following refs, which will"
.log( + " be auto-rebuilt at runtime: %s",
"Rebuilding detected a conflicting NoteDb update for the following refs, which will" e.getFailedRefs().stream().distinct().sorted().collect(joining(", ")));
+ " be auto-rebuilt at runtime: %s",
e.getFailedRefs().stream().distinct().sorted().collect(joining(", ")));
} catch (IOException e) { } catch (IOException e) {
logger.atSevere().withCause(e).log("Failed to save NoteDb state for %s", project); logger.atSevere().withCause(e).log("Failed to save NoteDb state for %s", project);
} finally { } finally {

View File

@@ -80,9 +80,8 @@ public class OnlineNoteDbMigrator implements LifecycleListener {
private void migrate() { private void migrate() {
logger.atInfo().log("Starting online NoteDb migration"); logger.atInfo().log("Starting online NoteDb migration");
if (upgradeIndex) { if (upgradeIndex) {
logger logger.atInfo().log(
.atInfo() "Online index schema upgrades will be deferred until NoteDb migration is complete");
.log("Online index schema upgrades will be deferred until NoteDb migration is complete");
} }
Stopwatch sw = Stopwatch.createStarted(); Stopwatch sw = Stopwatch.createStarted();
// TODO(dborowitz): Tune threads, maybe expose a progress monitor somewhere. // TODO(dborowitz): Tune threads, maybe expose a progress monitor somewhere.

View File

@@ -83,17 +83,15 @@ class IntraLineLoader implements Callable<IntraLineDiff> {
try { try {
return result.get(timeoutMillis, TimeUnit.MILLISECONDS); return result.get(timeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException | TimeoutException e) { } catch (InterruptedException | TimeoutException e) {
logger logger.atWarning().log(
.atWarning() "%s ms timeout reached for IntraLineDiff"
.log( + " in project %s on commit %s for path %s comparing %s..%s",
"%s ms timeout reached for IntraLineDiff" timeoutMillis,
+ " in project %s on commit %s for path %s comparing %s..%s", args.project(),
timeoutMillis, args.commit().name(),
args.project(), args.path(),
args.commit().name(), key.getBlobA().name(),
args.path(), key.getBlobB().name());
key.getBlobA().name(),
key.getBlobB().name());
result.cancel(true); result.cancel(true);
return new IntraLineDiff(IntraLineDiff.Status.TIMEOUT); return new IntraLineDiff(IntraLineDiff.Status.TIMEOUT);
} catch (ExecutionException e) { } catch (ExecutionException e) {

View File

@@ -448,17 +448,15 @@ public class PatchListLoader implements Callable<PatchList> {
try { try {
return result.get(timeoutMillis, TimeUnit.MILLISECONDS); return result.get(timeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException | TimeoutException e) { } catch (InterruptedException | TimeoutException e) {
logger logger.atWarning().log(
.atWarning() "%s ms timeout reached for Diff loader in project %s"
.log( + " on commit %s on path %s comparing %s..%s",
"%s ms timeout reached for Diff loader in project %s" timeoutMillis,
+ " on commit %s on path %s comparing %s..%s", project,
timeoutMillis, commitB.name(),
project, diffEntry.getNewPath(),
commitB.name(), diffEntry.getOldId().name(),
diffEntry.getNewPath(), diffEntry.getNewId().name());
diffEntry.getOldId().name(),
diffEntry.getNewId().name());
result.cancel(true); result.cancel(true);
synchronized (diffEntry) { synchronized (diffEntry) {
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry); return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);

View File

@@ -285,10 +285,8 @@ class DefaultRefFilter {
} catch (AuthException e) { } catch (AuthException e) {
return false; return false;
} catch (PermissionBackendException e) { } catch (PermissionBackendException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Failed to check permission for %s in %s", id, projectState.getName());
.withCause(e)
.log("Failed to check permission for %s in %s", id, projectState.getName());
return false; return false;
} }
} }
@@ -308,10 +306,8 @@ class DefaultRefFilter {
} }
return visibleChanges; return visibleChanges;
} catch (OrmException | PermissionBackendException e) { } catch (OrmException | PermissionBackendException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Cannot load changes for project %s, assuming no changes are visible", project);
.withCause(e)
.log("Cannot load changes for project %s, assuming no changes are visible", project);
return Collections.emptyMap(); return Collections.emptyMap();
} }
} }
@@ -322,10 +318,8 @@ class DefaultRefFilter {
try { try {
s = changeNotesFactory.scan(repo, db.get(), p); s = changeNotesFactory.scan(repo, db.get(), p);
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Cannot load changes for project %s, assuming no changes are visible", p);
.withCause(e)
.log("Cannot load changes for project %s, assuming no changes are visible", p);
return Collections.emptyMap(); return Collections.emptyMap();
} }
return s.map(this::toNotes) return s.map(this::toNotes)
@@ -336,10 +330,8 @@ class DefaultRefFilter {
@Nullable @Nullable
private ChangeNotes toNotes(ChangeNotesResult r) { private ChangeNotes toNotes(ChangeNotesResult r) {
if (r.error().isPresent()) { if (r.error().isPresent()) {
logger logger.atWarning().withCause(r.error().get()).log(
.atWarning() "Failed to load change %s in %s", r.id(), projectState.getName());
.withCause(r.error().get())
.log("Failed to load change %s in %s", r.id(), projectState.getName());
return null; return null;
} }
try { try {
@@ -348,10 +340,8 @@ class DefaultRefFilter {
return r.notes(); return r.notes();
} }
} catch (PermissionBackendException e) { } catch (PermissionBackendException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Failed to check permission for %s in %s", r.id(), projectState.getName());
.withCause(e)
.log("Failed to check permission for %s in %s", r.id(), projectState.getName());
} }
return null; return null;
} }
@@ -387,10 +377,8 @@ class DefaultRefFilter {
} catch (AuthException e) { } catch (AuthException e) {
return false; return false;
} catch (PermissionBackendException e) { } catch (PermissionBackendException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "Can't check permission for user %s on project %s", user, projectState.getName());
.withCause(e)
.log("Can't check permission for user %s on project %s", user, projectState.getName());
return false; return false;
} }
return true; return true;

View File

@@ -69,13 +69,11 @@ public enum GlobalPermission implements GlobalOrPluginPermission {
RequiresCapability rc = findAnnotation(clazz, RequiresCapability.class); RequiresCapability rc = findAnnotation(clazz, RequiresCapability.class);
RequiresAnyCapability rac = findAnnotation(clazz, RequiresAnyCapability.class); RequiresAnyCapability rac = findAnnotation(clazz, RequiresAnyCapability.class);
if (rc != null && rac != null) { if (rc != null && rac != null) {
logger logger.atSevere().log(
.atSevere() "Class %s uses both @%s and @%s",
.log( clazz.getName(),
"Class %s uses both @%s and @%s", RequiresCapability.class.getSimpleName(),
clazz.getName(), RequiresAnyCapability.class.getSimpleName());
RequiresCapability.class.getSimpleName(),
RequiresAnyCapability.class.getSimpleName());
throw new PermissionBackendException("cannot extract permission"); throw new PermissionBackendException("cannot extract permission");
} else if (rc != null) { } else if (rc != null) {
return Collections.singleton( return Collections.singleton(
@@ -124,11 +122,9 @@ public enum GlobalPermission implements GlobalOrPluginPermission {
} }
if (scope == CapabilityScope.PLUGIN) { if (scope == CapabilityScope.PLUGIN) {
logger logger.atSevere().log(
.atSevere() "Class %s uses @%s(scope=%s), but is not within a plugin",
.log( clazz.getName(), annotationClass.getSimpleName(), scope.name());
"Class %s uses @%s(scope=%s), but is not within a plugin",
clazz.getName(), annotationClass.getSimpleName(), scope.name());
throw new PermissionBackendException("cannot extract permission"); throw new PermissionBackendException("cannot extract permission");
} }

View File

@@ -282,10 +282,8 @@ public abstract class PermissionBackend {
// Do not include this project in allowed. // Do not include this project in allowed.
} catch (PermissionBackendException e) { } catch (PermissionBackendException e) {
if (e.getCause() instanceof RepositoryNotFoundException) { if (e.getCause() instanceof RepositoryNotFoundException) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Could not find repository of the project %s", project.get());
.withCause(e)
.log("Could not find repository of the project %s", project.get());
// Do not include this project because doesn't exist // Do not include this project because doesn't exist
} else { } else {
throw e; throw e;

View File

@@ -133,13 +133,10 @@ class AutoRegisterModules {
initJs = STATIC_INIT_JS; initJs = STATIC_INIT_JS;
} }
} catch (IOException e) { } catch (IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot access %s from plugin %s: "
.withCause(e) + "JavaScript auto-discovered plugin will not be registered",
.log( STATIC_INIT_JS, pluginName);
"Cannot access %s from plugin %s: "
+ "JavaScript auto-discovered plugin will not be registered",
STATIC_INIT_JS, pluginName);
} }
} }
@@ -155,11 +152,9 @@ class AutoRegisterModules {
Export export = clazz.getAnnotation(Export.class); Export export = clazz.getAnnotation(Export.class);
if (export == null) { if (export == null) {
logger logger.atWarning().log(
.atWarning() "In plugin %s asm incorrectly parsed %s with @Export(\"%s\")",
.log( pluginName, clazz.getName(), def.annotationValue);
"In plugin %s asm incorrectly parsed %s with @Export(\"%s\")",
pluginName, clazz.getName(), def.annotationValue);
return; return;
} }
@@ -193,9 +188,8 @@ class AutoRegisterModules {
if (listen != null) { if (listen != null) {
listen(clazz, clazz); listen(clazz, clazz);
} else { } else {
logger logger.atWarning().log(
.atWarning() "In plugin %s asm incorrectly parsed %s with @Listen", pluginName, clazz.getName());
.log("In plugin %s asm incorrectly parsed %s with @Listen", pluginName, clazz.getName());
} }
} }

View File

@@ -41,12 +41,9 @@ class CleanupHandle {
Files.deleteIfExists(tmp); Files.deleteIfExists(tmp);
logger.atInfo().log("Cleaned plugin %s", tmp.getFileName()); logger.atInfo().log("Cleaned plugin %s", tmp.getFileName());
} catch (IOException e) { } catch (IOException e) {
logger logger.atWarning().withCause(e).log(
.atWarning() "Cannot delete %s, retrying to delete it on termination of the virtual machine",
.withCause(e) tmp.toAbsolutePath());
.log(
"Cannot delete %s, retrying to delete it on termination of the virtual machine",
tmp.toAbsolutePath());
tmp.toFile().deleteOnExit(); tmp.toFile().deleteOnExit();
} }
} }

View File

@@ -91,12 +91,9 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
} catch (IOException err) { } catch (IOException err) {
throw new InvalidPluginException("Cannot auto-register", err); throw new InvalidPluginException("Cannot auto-register", err);
} catch (RuntimeException err) { } catch (RuntimeException err) {
logger logger.atWarning().withCause(err).log(
.atWarning() "Plugin %s has invalid class file %s inside of %s",
.withCause(err) pluginName, entry.getName(), jarFile.getName());
.log(
"Plugin %s has invalid class file %s inside of %s",
pluginName, entry.getName(), jarFile.getName());
continue; continue;
} }
@@ -104,11 +101,9 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
if (def.isConcrete()) { if (def.isConcrete()) {
rawMap.put(def.annotationName, def); rawMap.put(def.annotationName, def);
} else { } else {
logger logger.atWarning().log(
.atWarning() "Plugin %s tries to @%s(\"%s\") abstract class %s",
.log( pluginName, def.annotationName, def.annotationValue, def.className);
"Plugin %s tries to @%s(\"%s\") abstract class %s",
pluginName, def.annotationName, def.annotationValue, def.className);
} }
} }
} }
@@ -153,10 +148,8 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
try { try {
new ClassReader(read(jarFile, entry)).accept(def, SKIP_ALL); new ClassReader(read(jarFile, entry)).accept(def, SKIP_ALL);
} catch (RuntimeException err) { } catch (RuntimeException err) {
logger logger.atWarning().withCause(err).log(
.atWarning() "Jar %s has invalid class file %s", jarFile.getName(), entry.getName());
.withCause(err)
.log("Jar %s has invalid class file %s", jarFile.getName(), entry.getName());
continue; continue;
} }

View File

@@ -47,50 +47,45 @@ public class ListPlugins implements RestReadView<TopLevelResource> {
private String matchRegex; private String matchRegex;
@Option( @Option(
name = "--all", name = "--all",
aliases = {"-a"}, aliases = {"-a"},
usage = "List all plugins, including disabled plugins" usage = "List all plugins, including disabled plugins")
)
public void setAll(boolean all) { public void setAll(boolean all) {
this.all = all; this.all = all;
} }
@Option( @Option(
name = "--limit", name = "--limit",
aliases = {"-n"}, aliases = {"-n"},
metaVar = "CNT", metaVar = "CNT",
usage = "maximum number of plugins to list" usage = "maximum number of plugins to list")
)
public void setLimit(int limit) { public void setLimit(int limit) {
this.limit = limit; this.limit = limit;
} }
@Option( @Option(
name = "--start", name = "--start",
aliases = {"-S"}, aliases = {"-S"},
metaVar = "CNT", metaVar = "CNT",
usage = "number of plugins to skip" usage = "number of plugins to skip")
)
public void setStart(int start) { public void setStart(int start) {
this.start = start; this.start = start;
} }
@Option( @Option(
name = "--prefix", name = "--prefix",
aliases = {"-p"}, aliases = {"-p"},
metaVar = "PREFIX", metaVar = "PREFIX",
usage = "match plugin prefix" usage = "match plugin prefix")
)
public void setMatchPrefix(String matchPrefix) { public void setMatchPrefix(String matchPrefix) {
this.matchPrefix = matchPrefix; this.matchPrefix = matchPrefix;
} }
@Option( @Option(
name = "--match", name = "--match",
aliases = {"-m"}, aliases = {"-m"},
metaVar = "MATCH", metaVar = "MATCH",
usage = "match plugin substring" usage = "match plugin substring")
)
public void setMatchSubstring(String matchSubstring) { public void setMatchSubstring(String matchSubstring) {
this.matchSubstring = matchSubstring; this.matchSubstring = matchSubstring;
} }

View File

@@ -57,11 +57,9 @@ class PluginCleanerTask implements Runnable {
if (0 < left) { if (0 < left) {
long waiting = TimeUtil.nowMs() - start; long waiting = TimeUtil.nowMs() - start;
logger logger.atWarning().log(
.atWarning() "%d plugins still waiting to be reclaimed after %d minutes",
.log( pending, TimeUnit.MILLISECONDS.toMinutes(waiting));
"%d plugins still waiting to be reclaimed after %d minutes",
pending, TimeUnit.MILLISECONDS.toMinutes(waiting));
attempts = Math.min(attempts + 1, 15); attempts = Math.min(attempts + 1, 15);
ensureScheduled(); ensureScheduled();
} else { } else {

View File

@@ -167,11 +167,9 @@ public class PluginLoader implements LifecycleListener {
Path tmp = PluginUtil.asTemp(in, ".next_" + fileName + "_", ".tmp", pluginsDir); Path tmp = PluginUtil.asTemp(in, ".next_" + fileName + "_", ".tmp", pluginsDir);
String name = MoreObjects.firstNonNull(getGerritPluginName(tmp), PluginUtil.nameOf(fileName)); String name = MoreObjects.firstNonNull(getGerritPluginName(tmp), PluginUtil.nameOf(fileName));
if (!originalName.equals(name)) { if (!originalName.equals(name)) {
logger logger.atWarning().log(
.atWarning() "Plugin provides its own name: <%s>, use it instead of the input name: <%s>",
.log( name, originalName);
"Plugin provides its own name: <%s>, use it instead of the input name: <%s>",
name, originalName);
} }
String fileExtension = getExtension(fileName); String fileExtension = getExtension(fileName);
@@ -217,9 +215,8 @@ public class PluginLoader implements LifecycleListener {
public void disablePlugins(Set<String> names) { public void disablePlugins(Set<String> names) {
if (!isRemoteAdminEnabled()) { if (!isRemoteAdminEnabled()) {
logger logger.atWarning().log(
.atWarning() "Remote plugin administration is disabled, ignoring disablePlugins(%s)", names);
.log("Remote plugin administration is disabled, ignoring disablePlugins(%s)", names);
return; return;
} }
@@ -250,10 +247,8 @@ public class PluginLoader implements LifecycleListener {
disabled.put(name, offPlugin); disabled.put(name, offPlugin);
} catch (Throwable e) { } catch (Throwable e) {
// This shouldn't happen, as the plugin was loaded earlier. // This shouldn't happen, as the plugin was loaded earlier.
logger logger.atWarning().withCause(e.getCause()).log(
.atWarning() "Cannot load disabled plugin %s", active.getName());
.withCause(e.getCause())
.log("Cannot load disabled plugin %s", active.getName());
} }
} }
cleanInBackground(); cleanInBackground();
@@ -262,9 +257,8 @@ public class PluginLoader implements LifecycleListener {
public void enablePlugins(Set<String> names) throws PluginInstallException { public void enablePlugins(Set<String> names) throws PluginInstallException {
if (!isRemoteAdminEnabled()) { if (!isRemoteAdminEnabled()) {
logger logger.atWarning().log(
.atWarning() "Remote plugin administration is disabled, ignoring enablePlugins(%s)", names);
.log("Remote plugin administration is disabled, ignoring enablePlugins(%s)", names);
return; return;
} }
@@ -308,11 +302,8 @@ public class PluginLoader implements LifecycleListener {
try { try {
Files.delete(file); Files.delete(file);
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().log(
.atSevere() "Failed to remove stale plugin file %s: %s", file.toFile().getName(), e.getMessage());
.log(
"Failed to remove stale plugin file %s: %s",
file.toFile().getName(), e.getMessage());
} }
} }
} catch (IOException e) { } catch (IOException e) {
@@ -383,9 +374,8 @@ public class PluginLoader implements LifecycleListener {
try { try {
logger.atInfo().log("Reloading plugin %s", name); logger.atInfo().log("Reloading plugin %s", name);
Plugin newPlugin = runPlugin(name, active.getSrcFile(), active); Plugin newPlugin = runPlugin(name, active.getSrcFile(), active);
logger logger.atInfo().log(
.atInfo() "Reloaded plugin %s, version %s", newPlugin.getName(), newPlugin.getVersion());
.log("Reloaded plugin %s, version %s", newPlugin.getName(), newPlugin.getVersion());
} catch (PluginInstallException e) { } catch (PluginInstallException e) {
logger.atWarning().withCause(e.getCause()).log("Cannot reload plugin %s", name); logger.atWarning().withCause(e.getCause()).log("Cannot reload plugin %s", name);
throw e; throw e;
@@ -410,9 +400,8 @@ public class PluginLoader implements LifecycleListener {
Path path = entry.getValue(); Path path = entry.getValue();
String fileName = path.getFileName().toString(); String fileName = path.getFileName().toString();
if (!isUiPlugin(fileName) && !serverPluginFactory.handles(path)) { if (!isUiPlugin(fileName) && !serverPluginFactory.handles(path)) {
logger logger.atWarning().log(
.atWarning() "No Plugin provider was found that handles this file format: %s", fileName);
.log("No Plugin provider was found that handles this file format: %s", fileName);
continue; continue;
} }
@@ -433,13 +422,11 @@ public class PluginLoader implements LifecycleListener {
try { try {
Plugin loadedPlugin = runPlugin(name, path, active); Plugin loadedPlugin = runPlugin(name, path, active);
if (!loadedPlugin.isDisabled()) { if (!loadedPlugin.isDisabled()) {
logger logger.atInfo().log(
.atInfo() "%s plugin %s, version %s",
.log( active == null ? "Loaded" : "Reloaded",
"%s plugin %s, version %s", loadedPlugin.getName(),
active == null ? "Loaded" : "Reloaded", loadedPlugin.getVersion());
loadedPlugin.getName(),
loadedPlugin.getVersion());
} }
} catch (PluginInstallException e) { } catch (PluginInstallException e) {
logger.atWarning().withCause(e.getCause()).log("Cannot load plugin %s", name); logger.atWarning().withCause(e.getCause()).log("Cannot load plugin %s", name);
@@ -676,13 +663,11 @@ public class PluginLoader implements LifecycleListener {
Collection<Path> elementsToRemove = new ArrayList<>(); Collection<Path> elementsToRemove = new ArrayList<>();
Collection<Path> elementsToAdd = new ArrayList<>(); Collection<Path> elementsToAdd = new ArrayList<>();
for (Path loser : Iterables.skip(enabled, 1)) { for (Path loser : Iterables.skip(enabled, 1)) {
logger logger.atWarning().log(
.atWarning() "Plugin <%s> was disabled, because"
.log( + " another plugin <%s>"
"Plugin <%s> was disabled, because" + " with the same name <%s> already exists",
+ " another plugin <%s>" loser, winner, plugin);
+ " with the same name <%s> already exists",
loser, winner, plugin);
Path disabledPlugin = Paths.get(loser + ".disabled"); Path disabledPlugin = Paths.get(loser + ".disabled");
elementsToAdd.add(disabledPlugin); elementsToAdd.add(disabledPlugin);
elementsToRemove.add(loser); elementsToRemove.add(loser);

View File

@@ -159,9 +159,8 @@ public class ServerPlugin extends Plugin {
} else if ("restart".equalsIgnoreCase(v)) { } else if ("restart".equalsIgnoreCase(v)) {
return false; return false;
} else { } else {
logger logger.atWarning().log(
.atWarning() "Plugin %s has invalid Gerrit-ReloadMode %s; assuming restart", getName(), v);
.log("Plugin %s has invalid Gerrit-ReloadMode %s; assuming restart", getName(), v);
return false; return false;
} }
} }

View File

@@ -81,11 +81,9 @@ class UniversalServerPluginProvider implements ServerPluginProvider {
List<ServerPluginProvider> providers = new ArrayList<>(); List<ServerPluginProvider> providers = new ArrayList<>();
for (ServerPluginProvider serverPluginProvider : serverPluginProviders) { for (ServerPluginProvider serverPluginProvider : serverPluginProviders) {
boolean handles = serverPluginProvider.handles(srcPath); boolean handles = serverPluginProvider.handles(srcPath);
logger logger.atFine().log(
.atFine() "File %s handled by %s ? => %s",
.log( srcPath, serverPluginProvider.getProviderPluginName(), handles);
"File %s handled by %s ? => %s",
srcPath, serverPluginProvider.getProviderPluginName(), handles);
if (handles) { if (handles) {
providers.add(serverPluginProvider); providers.add(serverPluginProvider);
} }

View File

@@ -44,11 +44,9 @@ public class ConfiguredMimeTypes {
try { try {
add(typeName, path); add(typeName, path);
} catch (PatternSyntaxException | InvalidPatternException e) { } catch (PatternSyntaxException | InvalidPatternException e) {
logger logger.atWarning().log(
.atWarning() "Ignoring invalid %s.%s.%s = %s in project %s: %s",
.log( MIMETYPE, typeName, KEY_PATH, path, projectName, e.getMessage());
"Ignoring invalid %s.%s.%s = %s in project %s: %s",
MIMETYPE, typeName, KEY_PATH, path, projectName, e.getMessage());
} }
} }
} }

View File

@@ -84,10 +84,8 @@ public class CreateRefControl {
try (RevWalk rw = new RevWalk(repo)) { try (RevWalk rw = new RevWalk(repo)) {
rw.parseBody(tag); rw.parseBody(tag);
} catch (IOException e) { } catch (IOException e) {
logger logger.atSevere().withCause(e).log(
.atSevere() "RevWalk(%s) parsing %s:", branch.getParentKey(), tag.name());
.withCause(e)
.log("RevWalk(%s) parsing %s:", branch.getParentKey(), tag.name());
throw e; throw e;
} }

Some files were not shown because too many files have changed in this diff Show More