Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Remove unused elasticsearch library from WORKSPACE
  Use Logger's built-in formatting

Change-Id: I2d3dca1036a1a1a1a6e00331cab31c244bd78bc6
This commit is contained in:
David Pursehouse 2018-05-30 08:53:05 +09:00
commit 094671b459
39 changed files with 103 additions and 126 deletions

View File

@ -650,12 +650,6 @@ maven_jar(
# Test-only dependencies below.
maven_jar(
name = "elasticsearch",
artifact = "org.elasticsearch:elasticsearch:2.4.4",
sha1 = "e69930bc794c539d34778e665d6f8ccbffd42c6f",
)
maven_jar(
name = "jimfs",
artifact = "com.google.jimfs:jimfs:1.1",

View File

@ -101,15 +101,15 @@ class H2CacheFactory implements PersistentCacheFactory, LifecycleListener {
try {
Files.createDirectories(loc);
} catch (IOException e) {
log.warn("Can't create disk cache: " + loc.toAbsolutePath());
log.warn("Can't create disk cache: {}", loc.toAbsolutePath());
return null;
}
}
if (!Files.isWritable(loc)) {
log.warn("Can't write to disk cache: " + loc.toAbsolutePath());
log.warn("Can't write to disk cache: {}", loc.toAbsolutePath());
return null;
}
log.info("Enabling disk cache " + loc.toAbsolutePath());
log.info("Enabling disk cache {}", loc.toAbsolutePath());
return loc;
}
@ -134,7 +134,7 @@ class H2CacheFactory implements PersistentCacheFactory, LifecycleListener {
List<Runnable> pending = executor.shutdownNow();
if (executor.awaitTermination(15, TimeUnit.MINUTES)) {
if (pending != null && !pending.isEmpty()) {
log.info(String.format("Finishing %d disk cache updates", pending.size()));
log.info("Finishing {} disk cache updates", pending.size());
for (Runnable update : pending) {
update.run();
}

View File

@ -70,9 +70,9 @@ public class WebSessionManager {
SECONDS));
if (sessionMaxAgeMillis < MINUTES.toMillis(5)) {
log.warn(
String.format(
"cache.%s.maxAge is set to %d milliseconds; it should be at least 5 minutes.",
CACHE_NAME, sessionMaxAgeMillis));
"cache.{}.maxAge is set to {} milliseconds; it should be at least 5 minutes.",
CACHE_NAME,
sessionMaxAgeMillis);
}
}

View File

@ -53,8 +53,7 @@ public class WarDistribution implements PluginsDistribution {
try (InputStream in = zf.getInputStream(ze)) {
processor.process(pluginName, in);
} catch (IOException ioe) {
log.error(
String.format("Error opening plugin %s: %s", ze.getName(), ioe.getMessage()));
log.error("Error opening plugin {}: {}", ze.getName(), ioe.getMessage());
}
}
}

View File

@ -266,9 +266,9 @@ public class ApprovalsUtil {
return permissionBackend.user(user).change(notes).database(db).test(ChangePermission.READ);
} catch (PermissionBackendException e) {
log.warn(
String.format(
"Failed to check if account %d can see change %d",
accountId.get(), notes.getChangeId().get()),
"Failed to check if account {} can see change {}",
accountId.get(),
notes.getChangeId().get(),
e);
return false;
}

View File

@ -304,9 +304,9 @@ public class StarredChangesUtil {
return ref != null ? ref.getObjectId() : ObjectId.zeroId();
} catch (IOException e) {
log.error(
String.format(
"Getting star object ID for account %d on change %d failed",
accountId.get(), changeId.get()),
"Getting star object ID for account {} on change {} failed",
accountId.get(),
changeId.get(),
e);
return ObjectId.zeroId();
}

View File

@ -67,9 +67,7 @@ public class AccountDeactivator implements Runnable {
if (delay == MISSING_CONFIG && interval == MISSING_CONFIG) {
log.info("Ignoring missing accountDeactivator schedule configuration");
} else if (delay < 0 || interval <= 0) {
log.warn(
String.format(
"Ignoring invalid accountDeactivator schedule configuration: %s", scheduleConfig));
log.warn("Ignoring invalid accountDeactivator schedule configuration: {}", scheduleConfig);
} else {
queue
.getDefaultQueue()

View File

@ -94,8 +94,7 @@ public class AccountState {
try {
return HashedPassword.decode(hashedStr).checkPassword(password);
} catch (DecoderException e) {
logger.error(
String.format("DecoderException for user %s: %s ", username, e.getMessage()));
logger.error("DecoderException for user {}: {}", username, e.getMessage());
return false;
}
}

View File

@ -86,7 +86,7 @@ public class Accounts {
try {
accounts.add(read(repo, accountId));
} catch (Exception e) {
log.error(String.format("Ignoring invalid account %s", accountId.get()), e);
log.error("Ignoring invalid account {}", accountId.get(), e);
}
}
}

View File

@ -112,7 +112,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
try {
return groupsWithMember.get(memberId);
} catch (ExecutionException e) {
log.warn(String.format("Cannot load groups containing %d as member", memberId.get()));
log.warn("Cannot load groups containing {} as member", memberId.get());
return ImmutableSet.of();
}
}

View File

@ -140,7 +140,7 @@ public class ExternalIdReader {
try {
extIds.add(ExternalId.parse(note.getName(), raw, note.getData()));
} catch (Exception e) {
log.error(String.format("Ignoring invalid external ID note %s", note.getName()), e);
log.error("Ignoring invalid external ID note {}", note.getName(), e);
}
}
return extIds;

View File

@ -64,9 +64,7 @@ public class ChangeCleanupRunner implements Runnable {
if (delay == MISSING_CONFIG && interval == MISSING_CONFIG) {
log.info("Ignoring missing changeCleanup schedule configuration");
} else if (delay < 0 || interval <= 0) {
log.warn(
String.format(
"Ignoring invalid changeCleanup schedule configuration: %s", scheduleConfig));
log.warn("Ignoring invalid changeCleanup schedule configuration: {}", scheduleConfig);
} else {
@SuppressWarnings("unused")
Future<?> possiblyIgnoredError =

View File

@ -473,9 +473,9 @@ public class ChangeInserter implements InsertChangeOp {
.test(ChangePermission.READ);
} catch (PermissionBackendException e) {
log.warn(
String.format(
"Failed to check if account %d can see change %d",
accountId.get(), notes.getChangeId().get()),
"Failed to check if account {} can see change {}",
accountId.get(),
notes.getChangeId().get(),
e);
return false;
}
@ -501,7 +501,7 @@ public class ChangeInserter implements InsertChangeOp {
cm.addExtraCC(extraCC);
cm.send();
} catch (Exception e) {
log.error("Cannot send email for new change " + change.getId(), e);
log.error("Cannot send email for new change {}", change.getId(), e);
}
}

View File

@ -186,7 +186,7 @@ public class ChangeResource implements RestResource, HasETag {
try {
projectStateTree = projectCache.checkedGet(getProject()).tree();
} catch (IOException e) {
log.error(String.format("could not load project %s while computing etag", getProject()));
log.error("could not load project {} while computing etag", getProject());
projectStateTree = ImmutableList.of();
}

View File

@ -217,9 +217,10 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
});
} catch (ExecutionException | UncheckedExecutionException e) {
log.error(
String.format(
"Error checking mergeability of %s into %s (%s)",
key.commit.name(), key.into.name(), key.submitType.name()),
"Error checking mergeability of {} into {} ({})",
key.commit.name(),
key.into.name(),
key.submitType.name(),
e.getCause());
return false;
}

View File

@ -69,10 +69,7 @@ public class RebaseUtil {
} catch (RestApiException e) {
return false;
} catch (OrmException | IOException e) {
log.warn(
String.format(
"Error checking if patch set %s on %s can be rebased", patchSet.getId(), dest),
e);
log.warn("Error checking if patch set {} on {} can be rebased", patchSet.getId(), dest, e);
return false;
}
}

View File

@ -61,10 +61,8 @@ public class ListCapabilities implements RestReadView<ConfigResource> {
for (String pluginName : pluginCapabilities.plugins()) {
if (!isPluginNameSane(pluginName)) {
log.warn(
String.format(
"Plugin name %s must match [A-Za-z0-9-]+ to use capabilities;"
+ " rename the plugin",
pluginName));
"Plugin name {} must match [A-Za-z0-9-]+ to use capabilities;" + " rename the plugin",
pluginName);
continue;
}
for (Map.Entry<String, Provider<CapabilityDefinition>> entry :

View File

@ -350,9 +350,7 @@ public class ProjectConfigEntry {
}
}
} catch (IOException | ConfigInvalidException e) {
log.error(
String.format("Failed to check if plugin config of project %s was updated.", p.get()),
e);
log.error("Failed to check if plugin config of project {} was updated.", p.get(), e);
}
}

View File

@ -504,7 +504,7 @@ public class EventFactory {
} catch (IOException | OrmException e) {
log.error("Cannot load patch set data for {}", patchSet.getId(), e);
} catch (PatchListObjectTooLargeException e) {
log.warn(String.format("Cannot get size information for %s: %s", pId, e.getMessage()));
log.warn("Cannot get size information for {}: {}", pId, e.getMessage());
} catch (PatchListNotAvailableException e) {
log.error("Cannot get size information for {}.", pId, e);
}

View File

@ -105,8 +105,7 @@ public class UiActions {
try {
view = e.getProvider().get();
} catch (RuntimeException err) {
log.error(
String.format("error creating view %s.%s", e.getPluginName(), e.getExportName()), err);
log.error("error creating view {}.{}", e.getPluginName(), e.getExportName(), err);
return null;
}
@ -123,8 +122,7 @@ public class UiActions {
try {
globalRequired = GlobalPermission.fromAnnotation(e.getPluginName(), view.getClass());
} catch (PermissionBackendException err) {
log.error(
String.format("exception testing view %s.%s", e.getPluginName(), e.getExportName()), err);
log.error("exception testing view {}.{}", e.getPluginName(), e.getExportName(), err);
return null;
}
if (!globalRequired.isEmpty()) {

View File

@ -46,9 +46,13 @@ public class ConfiguredMimeTypes {
add(typeName, path);
} catch (PatternSyntaxException | InvalidPatternException e) {
log.warn(
String.format(
"Ignoring invalid %s.%s.%s = %s in project %s: %s",
MIMETYPE, typeName, KEY_PATH, path, projectName, e.getMessage()));
"Ignoring invalid {}.{}.{} = {} in project {}: {}",
MIMETYPE,
typeName,
KEY_PATH,
path,
projectName,
e.getMessage());
}
}
}

View File

@ -216,9 +216,9 @@ public class MultiProgressMonitor {
"(timeout %sms, cancelled)",
TimeUnit.MILLISECONDS.convert(now - deadline, NANOSECONDS));
log.warn(
String.format(
"MultiProgressMonitor worker killed after %sms" + detailMessage, //
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS)));
"MultiProgressMonitor worker killed after {}ms {}",
TimeUnit.MILLISECONDS.convert(now - overallStart, NANOSECONDS),
detailMessage);
}
break;
}

View File

@ -359,9 +359,9 @@ public class VisibleRefFilter extends AbstractAdvertiseRefsHook {
return false;
} catch (PermissionBackendException e) {
log.error(
String.format(
"Can't check permission for user %s on project %s",
user.get(), projectState.getName()),
"Can't check permission for user {} on project {}",
user.get(),
projectState.getName(),
e);
return false;
}

View File

@ -267,9 +267,8 @@ public class AsyncReceiveCommits implements PreReceiveHook {
executor.submit(scopePropagator.wrap(w)), timeoutMillis, TimeUnit.MILLISECONDS);
} catch (ExecutionException e) {
log.warn(
String.format(
"Error in ReceiveCommits while processing changes for project %s",
projectControl.getProject().getName()),
"Error in ReceiveCommits while processing changes for project {}",
projectControl.getProject().getName(),
e);
rp.sendError("internal error while processing changes");
// ReceiveCommits has tried its best to catch errors, so anything at this

View File

@ -67,9 +67,7 @@ public class ListSubgroups implements RestReadView<GroupResource> {
included.add(json.format(i.getGroup()));
}
} catch (NoSuchGroupException notFound) {
log.warn(
String.format(
"Group %s no longer available, subgroup of %s", subgroupUuid, group.getName()));
log.warn("Group {} no longer available, subgroup of {}", subgroupUuid, group.getName());
continue;
}
}

View File

@ -92,7 +92,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
try {
accountCache.evict(accountId);
} catch (IOException e) {
log.error(String.format("Reindex account %s failed.", accountId), e);
log.error("Reindex account {} failed.", accountId, e);
}
}
}

View File

@ -83,11 +83,10 @@ public enum GlobalPermission implements GlobalOrPluginPermission {
RequiresAnyCapability rac = findAnnotation(clazz, RequiresAnyCapability.class);
if (rc != null && rac != null) {
log.error(
String.format(
"Class %s uses both @%s and @%s",
clazz.getName(),
RequiresCapability.class.getSimpleName(),
RequiresAnyCapability.class.getSimpleName()));
"Class {} uses both @{} and @{}",
clazz.getName(),
RequiresCapability.class.getSimpleName(),
RequiresAnyCapability.class.getSimpleName());
throw new PermissionBackendException("cannot extract permission");
} else if (rc != null) {
return Collections.singleton(
@ -154,16 +153,16 @@ public enum GlobalPermission implements GlobalOrPluginPermission {
if (scope == CapabilityScope.PLUGIN) {
log.error(
String.format(
"Class %s uses @%s(scope=%s), but is not within a plugin",
clazz.getName(), annotationClass.getSimpleName(), scope.name()));
"Class {} uses @{}(scope={}), but is not within a plugin",
clazz.getName(),
annotationClass.getSimpleName(),
scope.name());
throw new PermissionBackendException("cannot extract permission");
}
GlobalPermission perm = byName(capability);
if (perm == null) {
log.error(
String.format("Class %s requires unknown capability %s", clazz.getName(), capability));
log.error("Class {} requires unknown capability {}", clazz.getName(), capability);
throw new PermissionBackendException("cannot extract permission");
}
return perm;

View File

@ -135,10 +135,10 @@ class AutoRegisterModules {
}
} catch (IOException e) {
log.warn(
String.format(
"Cannot access %s from plugin %s: "
+ "JavaScript auto-discovered plugin will not be registered",
STATIC_INIT_JS, pluginName),
"Cannot access {} from plugin {}: "
+ "JavaScript auto-discovered plugin will not be registered",
STATIC_INIT_JS,
pluginName,
e);
}
}
@ -156,9 +156,10 @@ class AutoRegisterModules {
Export export = clazz.getAnnotation(Export.class);
if (export == null) {
log.warn(
String.format(
"In plugin %s asm incorrectly parsed %s with @Export(\"%s\")",
pluginName, clazz.getName(), def.annotationValue));
"In plugin {} asm incorrectly parsed {} with @Export(\"{}\")",
pluginName,
clazz.getName(),
def.annotationValue);
return;
}
@ -192,9 +193,7 @@ class AutoRegisterModules {
if (listen != null) {
listen(clazz, clazz);
} else {
log.warn(
String.format(
"In plugin %s asm incorrectly parsed %s with @Listen", pluginName, clazz.getName()));
log.warn("In plugin {} asm incorrectly parsed {} with @Listen", pluginName, clazz.getName());
}
}

View File

@ -92,9 +92,10 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
throw new InvalidPluginException("Cannot auto-register", err);
} catch (RuntimeException err) {
log.warn(
String.format(
"Plugin %s has invalid class file %s inside of %s",
pluginName, entry.getName(), jarFile.getName()),
"Plugin {} has invalid class file {} inside of {}",
pluginName,
entry.getName(),
jarFile.getName(),
err);
continue;
}
@ -104,9 +105,11 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
rawMap.put(def.annotationName, def);
} else {
log.warn(
String.format(
"Plugin %s tries to @%s(\"%s\") abstract class %s",
pluginName, def.annotationName, def.annotationValue, def.className));
"Plugin {} tries to @{}(\"{}\") abstract class {}",
pluginName,
def.annotationName,
def.annotationValue,
def.className);
}
}
}
@ -151,9 +154,7 @@ public class JarScanner implements PluginContentScanner, AutoCloseable {
try {
new ClassReader(read(jarFile, entry)).accept(def, SKIP_ALL);
} catch (RuntimeException err) {
log.warn(
String.format("Jar %s has invalid class file %s", jarFile.getName(), entry.getName()),
err);
log.warn("Jar {} has invalid class file {}", jarFile.getName(), entry.getName(), err);
continue;
}

View File

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

View File

@ -178,9 +178,7 @@ public class ServerPlugin extends Plugin {
} else if ("restart".equalsIgnoreCase(v)) {
return false;
} else {
log.warn(
String.format(
"Plugin %s has invalid Gerrit-ReloadMode %s; assuming restart", getName(), v));
log.warn("Plugin {} has invalid Gerrit-ReloadMode {}; assuming restart", getName(), v);
return false;
}
}

View File

@ -116,7 +116,7 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
return true;
}
} catch (OrmException e) {
log.error("Cannot look up change for commit " + commit.name() + " in " + project, e);
log.error("Cannot look up change for commit {} in {}", commit.name(), project, e);
}
}
@ -130,9 +130,9 @@ public class CommitsCollection implements ChildCollection<ProjectResource, Commi
return IncludedInResolver.includedInAny(repo, rw, commit, refs.values());
} catch (IOException e) {
log.error(
String.format(
"Cannot verify permissions to commit object %s in repository %s",
commit.name(), state.getNameKey()),
"Cannot verify permissions to commit object {} in repository {}",
commit.name(),
state.getNameKey(),
e);
return false;
}

View File

@ -81,7 +81,7 @@ public class CreateRefControl {
try (RevWalk rw = new RevWalk(repo)) {
rw.parseBody(tag);
} catch (IOException e) {
log.error(String.format("RevWalk(%s) parsing %s:", branch.getParentKey(), tag.name()), e);
log.error("RevWalk({}) parsing {}:", branch.getParentKey(), tag.name(), e);
throw e;
}

View File

@ -142,9 +142,11 @@ public class ListDashboards implements RestReadView<ProjectResource> {
setDefault));
} catch (ConfigInvalidException e) {
log.warn(
String.format(
"Cannot parse dashboard %s:%s:%s: %s",
definingProject.getName(), ref.getName(), tw.getPathString(), e.getMessage()));
"Cannot parse dashboard {}:{}:{}: {}",
definingProject.getName(),
ref.getName(),
tw.getPathString(),
e.getMessage());
}
}
}

View File

@ -505,9 +505,7 @@ public class ListProjects implements RestReadView<TopLevelResource> {
if (projectCache.get(parent) != null) {
parents.add(parent);
} else {
log.warn(
String.format(
"parent project %s of project %s not found", parent.get(), ps.getName()));
log.warn("parent project {} of project {} not found", parent.get(), ps.getName());
}
}
}

View File

@ -142,7 +142,7 @@ public class ProjectCacheImpl implements ProjectCache {
return strictCheckedGet(projectName);
} catch (Exception e) {
if (!(e.getCause() instanceof RepositoryNotFoundException)) {
log.warn(String.format("Cannot read project %s", projectName.get()), e);
log.warn("Cannot read project {}", projectName.get(), e);
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
throw new IOException(e);
}

View File

@ -382,9 +382,9 @@ public class ProjectControl {
return commits.isReachableFrom(state, repo, commit, refs);
} catch (IOException e) {
log.error(
String.format(
"Cannot verify permissions to commit object %s in repository %s",
commit.name(), getProject().getNameKey()),
"Cannot verify permissions to commit object {} in repository {}",
commit.name(),
getProject().getNameKey(),
e);
return false;
}

View File

@ -76,7 +76,7 @@ public class InternalGroupQuery extends InternalQuery<InternalGroup> {
ImmutableList<AccountGroup.UUID> groupUuids =
groups.stream().map(InternalGroup::getGroupUUID).collect(toImmutableList());
log.warn(String.format("Ambiguous %s for groups %s.", groupDescription, groupUuids));
log.warn("Ambiguous {} for groups {}.", groupDescription, groupUuids);
return Optional.empty();
}
}

View File

@ -66,9 +66,8 @@ class SshPluginStarterCallback implements StartPluginListener, ReloadPluginListe
} catch (RuntimeException err) {
if (!providesDynamicOptions(plugin)) {
log.warn(
String.format(
"Plugin %s did not define its top-level command nor any DynamicOptions",
plugin.getName()),
"Plugin {} did not define its top-level command nor any DynamicOptions",
plugin.getName(),
err);
}
}