Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  Use Logger's built-in string formatting where possible
  Doc: Fix code example in JS API

Change-Id: I1b953b6d9ab5cd066b8b6f43bb1843dcb1736d1b
This commit is contained in:
David Pursehouse
2018-05-23 20:17:58 +09:00
26 changed files with 116 additions and 124 deletions

View File

@@ -769,7 +769,7 @@ Gerrit.get(url, callback)
----
Gerrit.get('/changes/?q=status:open', function (open) {
for (var i = 0; i < open.length; i++) {
console.log(open.get(i).change_id);
console.log(open[i].change_id);
}
});
----

View File

@@ -191,7 +191,7 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
try {
filter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
} catch (RuntimeException e) {
log.warn(String.format("Plugin %s cannot load GuiceFilter", name), e);
log.warn("Plugin {} cannot load GuiceFilter", name, e);
return null;
}
@@ -199,7 +199,7 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
ServletContext ctx = PluginServletContext.create(plugin, wrapper.getFullPath(name));
filter.init(new WrappedFilterConfig(ctx));
} catch (ServletException e) {
log.warn(String.format("Plugin %s failed to initialize HTTP", name), e);
log.warn("Plugin {} failed to initialize HTTP", name, e);
return null;
}
@@ -430,10 +430,11 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
&& size.isPresent()) {
if (size.get() <= 0 || size.get() > SMALL_RESOURCE) {
log.warn(
String.format(
"Plugin %s: %s omitted from document index. "
+ "Size %d out of range (0,%d).",
pluginName, name.substring(prefix.length()), size.get(), SMALL_RESOURCE));
"Plugin {}: {} omitted from document index. Size {} out of range (0,{}).",
pluginName,
name.substring(prefix.length()),
size.get(),
SMALL_RESOURCE);
return false;
}
return true;
@@ -456,9 +457,9 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
about = entry;
} else {
log.warn(
String.format(
"Plugin %s: Multiple 'about' documents found; using %s",
pluginName, about.getName().substring(prefix.length())));
"Plugin {}: Multiple 'about' documents found; using {}",
pluginName,
about.getName().substring(prefix.length()));
}
} else {
docs.add(entry);
@@ -736,9 +737,7 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
}
return def;
} catch (IOException e) {
log.warn(
String.format("Error getting %s for plugin %s, using default", attr, plugin.getName()),
e);
log.warn("Error getting {} for plugin {}, using default", attr, plugin.getName(), e);
return null;
}
}

View File

@@ -139,7 +139,7 @@ public class LfsPluginServlet extends HttpServlet
try {
guiceFilter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
} catch (RuntimeException e) {
log.warn(String.format("Plugin %s cannot load GuiceFilter", name), e);
log.warn("Plugin {} cannot load GuiceFilter", name, e);
return null;
}
@@ -147,7 +147,7 @@ public class LfsPluginServlet extends HttpServlet
ServletContext ctx = PluginServletContext.create(plugin, "/");
guiceFilter.init(new WrappedFilterConfig(ctx));
} catch (ServletException e) {
log.warn(String.format("Plugin %s failed to initialize HTTP", name), e);
log.warn("Plugin {} failed to initialize HTTP", name, e);
return null;
}

View File

@@ -155,7 +155,7 @@ class PluginServletContext {
@Override
public void log(String msg, Throwable reason) {
log.warn(String.format("[plugin %s] %s", plugin.getName(), msg), reason);
log.warn("[plugin {}] {}", plugin.getName(), msg, reason);
}
@Override

View File

@@ -161,7 +161,7 @@ public abstract class ResourceServlet extends HttpServlet {
r = cache.get(p, newLoader(p));
}
} catch (ExecutionException e) {
log.warn("Cannot load static resource " + req.getPathInfo(), e);
log.warn("Cannot load static resource {}", req.getPathInfo(), e);
CacheHeaders.setNotCacheable(rsp);
rsp.setStatus(SC_INTERNAL_SERVER_ERROR);
return;
@@ -214,12 +214,12 @@ public abstract class ResourceServlet extends HttpServlet {
try {
Path p = getResourcePath(name);
if (p == null) {
log.warn(String.format("Path doesn't exist %s", name));
log.warn("Path doesn't exist {}", name);
return null;
}
return cache.get(p, newLoader(p));
} catch (ExecutionException | IOException e) {
log.warn(String.format("Cannot load static resource %s", name), e);
log.warn("Cannot load static resource {}", name, e);
return null;
}
}

View File

@@ -1172,7 +1172,7 @@ public class RestApiServlet extends HttpServlet {
if (!Strings.isNullOrEmpty(req.getQueryString())) {
uri += "?" + req.getQueryString();
}
log.error(String.format("Error in %s %s", req.getMethod(), uri), err);
log.error("Error in {} {}", req.getMethod(), uri, err);
if (!res.isCommitted()) {
res.reset();

View File

@@ -184,7 +184,7 @@ public class Schema<T> {
try {
v = f.get(obj);
} catch (OrmException e) {
log.error(String.format("error getting field %s of %s", f.getName(), obj), e);
log.error("error getting field {} of {}", f.getName(), obj, e);
return null;
}
if (v == null) {

View File

@@ -68,7 +68,7 @@ public class SwitchSecureStore extends SiteProgram {
SitePaths sitePaths = new SitePaths(getSitePath());
Path newSecureStorePath = Paths.get(newSecureStoreLib);
if (!Files.exists(newSecureStorePath)) {
log.error(String.format("File %s doesn't exist", newSecureStorePath.toAbsolutePath()));
log.error("File {} doesn't exist", newSecureStorePath.toAbsolutePath());
return -1;
}
@@ -77,8 +77,7 @@ public class SwitchSecureStore extends SiteProgram {
if (currentSecureStoreName.equals(newSecureStore)) {
log.error(
"Old and new SecureStore implementation names "
+ "are the same. Migration will not work");
"Old and new SecureStore implementation names are the same. Migration will not work");
return -1;
}

View File

@@ -79,7 +79,7 @@ class HiddenErrorHandler extends ErrorHandler {
if (!Strings.isNullOrEmpty(req.getQueryString())) {
uri += "?" + req.getQueryString();
}
log.error(String.format("Error in %s %s", req.getMethod(), uri), err);
log.error("Error in {} {}", req.getMethod(), uri, err);
}
}
}

View File

@@ -49,7 +49,7 @@ public class WebLinks {
if (link == null) {
return false;
} else if (Strings.isNullOrEmpty(link.name) || Strings.isNullOrEmpty(link.url)) {
log.warn(String.format("%s is missing name and/or url", link.getClass().getName()));
log.warn("{} is missing name and/or url", link.getClass().getName());
return false;
}
return true;
@@ -60,7 +60,7 @@ public class WebLinks {
if (link == null) {
return false;
} else if (Strings.isNullOrEmpty(link.name) || Strings.isNullOrEmpty(link.url)) {
log.warn(String.format("%s is missing name and/or url", link.getClass().getName()));
log.warn("{} is missing name and/or url", link.getClass().getName());
return false;
}
return true;

View File

@@ -88,7 +88,7 @@ public class GroupCacheImpl implements GroupCache {
try {
return byId.get(groupId);
} catch (ExecutionException e) {
log.warn("Cannot load group " + groupId, e);
log.warn("Cannot load group {}", groupId, e);
return Optional.empty();
}
}
@@ -124,7 +124,7 @@ public class GroupCacheImpl implements GroupCache {
try {
return byName.get(name.get());
} catch (ExecutionException e) {
log.warn(String.format("Cannot look up group %s by name", name.get()), e);
log.warn("Cannot look up group {} by name", name.get(), e);
return Optional.empty();
}
}
@@ -138,7 +138,7 @@ public class GroupCacheImpl implements GroupCache {
try {
return byUUID.get(groupUuid.get());
} catch (ExecutionException e) {
log.warn(String.format("Cannot look up group %s by uuid", groupUuid.get()), e);
log.warn("Cannot look up group {} by uuid", groupUuid.get(), e);
return Optional.empty();
}
}

View File

@@ -126,7 +126,7 @@ public class LdapGroupBackend implements GroupBackend {
return null;
}
} catch (ExecutionException e) {
log.warn(String.format("Cannot lookup group %s in LDAP", groupDn), e);
log.warn("Cannot lookup group {} in LDAP", groupDn, e);
return null;
}
}

View File

@@ -65,7 +65,7 @@ class LdapGroupMembership implements GroupMembership {
try {
membership = new ListGroupMembership(membershipCache.get(id));
} catch (ExecutionException e) {
LdapGroupBackend.log.warn(String.format("Cannot lookup membershipsOf %s in LDAP", id), e);
LdapGroupBackend.log.warn("Cannot lookup membershipsOf {} in LDAP", id, e);
membership = GroupMembership.EMPTY;
}
}

View File

@@ -315,7 +315,7 @@ class LdapRealm extends AbstractRealm {
Optional<Account.Id> id = usernameCache.get(accountName);
return id != null ? id.orElse(null) : null;
} catch (ExecutionException e) {
log.warn(String.format("Cannot lookup account %s in LDAP", accountName), e);
log.warn("Cannot lookup account {} in LDAP", accountName, e);
return null;
}
}

View File

@@ -96,7 +96,7 @@ public class AbandonUtil {
log.error(msg.toString(), e);
}
}
log.info(String.format("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size()));
log.info("Auto-Abandoned {} of {} changes.", count, changesToAbandon.size());
} catch (QueryParseException | OrmException e) {
log.error("Failed to query inactive open changes for auto-abandoning.", e);
}

View File

@@ -151,7 +151,7 @@ public class EventFactory {
try {
a.commitMessage = changeDataFactory.create(db, change).commitMessage();
} catch (Exception e) {
log.error("Error while getting full commit message for change " + a.number, e);
log.error("Error while getting full commit message for change {}", a.number, e);
}
a.url = getChangeUrl(change);
a.owner = asAccountAttribute(change.getOwner());
@@ -502,11 +502,11 @@ public class EventFactory {
}
p.kind = changeKindCache.getChangeKind(db, change, patchSet);
} catch (IOException | OrmException e) {
log.error("Cannot load patch set data for " + patchSet.getId(), 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()));
} catch (PatchListNotAvailableException e) {
log.error(String.format("Cannot get size information for %s.", pId), e);
log.error("Cannot get size information for {}.", pId, e);
}
return p;
}

View File

@@ -119,9 +119,9 @@ public class EventUtil {
public void logEventListenerError(Object event, Object listener, Exception error) {
if (log.isDebugEnabled()) {
log.debug(
String.format(
"Error in event listener %s for event %s",
listener.getClass().getName(), event.getClass().getName()),
"Error in event listener {} for event {}",
listener.getClass().getName(),
event.getClass().getName(),
error);
} else {
log.warn(
@@ -134,7 +134,7 @@ public class EventUtil {
public static void logEventListenerError(Object listener, Exception error) {
if (log.isDebugEnabled()) {
log.debug(String.format("Error in event listener %s", listener.getClass().getName()), error);
log.debug("Error in event listener {}", listener.getClass().getName(), error);
} else {
log.warn("Error in event listener {}: {}", listener.getClass().getName(), error.getMessage());
}

View File

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

View File

@@ -100,7 +100,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
} else {
desc = String.format("%d", limit);
}
log.info(String.format("Defaulting core.streamFileThreshold to %s", desc));
log.info("Defaulting core.streamFileThreshold to {}", desc);
cfg.setStreamFileThreshold(limit);
}
cfg.install();
@@ -226,9 +226,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
//
File metaConfigLog = new File(db.getDirectory(), "logs/" + RefNames.REFS_CONFIG);
if (!metaConfigLog.getParentFile().mkdirs() || !metaConfigLog.createNewFile()) {
log.error(
String.format(
"Failed to create ref log for %s in repository %s", RefNames.REFS_CONFIG, name));
log.error("Failed to create ref log for {} in repository {}", RefNames.REFS_CONFIG, name);
}
onCreateProject(name);
@@ -306,7 +304,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
Integer.MAX_VALUE,
visitor);
} catch (IOException e) {
log.error("Error walking repository tree " + visitor.startFolder.toAbsolutePath(), e);
log.error("Error walking repository tree {}", visitor.startFolder.toAbsolutePath(), e);
}
}
@@ -361,7 +359,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
Project.NameKey nameKey = getProjectName(startFolder, p);
if (getBasePath(nameKey).equals(startFolder)) {
if (isUnreasonableName(nameKey)) {
log.warn("Ignoring unreasonably named repository " + p.toAbsolutePath());
log.warn("Ignoring unreasonably named repository {}", p.toAbsolutePath());
} else {
found.add(nameKey);
}

View File

@@ -214,7 +214,7 @@ public class StalenessChecker {
}
return false;
} catch (IOException e) {
log.warn(String.format("error checking staleness of %s in %s", id, project), e);
log.warn("error checking staleness of {} in {}", id, project, e);
return true;
}
}

View File

@@ -140,9 +140,10 @@ public class MailProcessor {
for (DynamicMap.Entry<MailFilter> filter : mailFilters) {
if (!filter.getProvider().get().shouldProcessMessage(message)) {
log.warn(
String.format(
"Message %s filtered by plugin %s %s. Will delete message.",
message.id(), filter.getPluginName(), filter.getExportName()));
"Message {} filtered by plugin {} {}. Will delete message.",
message.id(),
filter.getPluginName(),
filter.getExportName());
return;
}
}
@@ -150,23 +151,24 @@ public class MailProcessor {
MailMetadata metadata = MetadataParser.parse(message);
if (!metadata.hasRequiredFields()) {
log.error(
String.format(
"Message %s is missing required metadata, have %s. Will delete message.",
message.id(), metadata));
"Message {} is missing required metadata, have {}. Will delete message.",
message.id(),
metadata);
return;
}
Set<Account.Id> accountIds = emails.getAccountFor(metadata.author);
if (accountIds.size() != 1) {
log.error(
String.format(
"Address %s could not be matched to a unique account. It was matched to %s. Will delete message.",
metadata.author, accountIds));
"Address {} could not be matched to a unique account. It was matched to {}."
+ " Will delete message.",
metadata.author,
accountIds);
return;
}
Account.Id account = accountIds.iterator().next();
if (!accountCache.get(account).getAccount().isActive()) {
log.warn(String.format("Mail: Account %s is inactive. Will delete message.", account));
log.warn("Mail: Account {} is inactive. Will delete message.", account);
return;
}
@@ -181,15 +183,16 @@ public class MailProcessor {
queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
if (changeDataList.size() != 1) {
log.error(
String.format(
"Message %s references unique change %s, but there are %d matching changes in the index. Will delete message.",
message.id(), metadata.changeNumber, changeDataList.size()));
"Message {} references unique change {}, but there are {} matching changes in "
+ "the index. Will delete message.",
message.id(),
metadata.changeNumber,
changeDataList.size());
return;
}
ChangeData cd = changeDataList.get(0);
if (existingMessageIds(cd).contains(message.id())) {
log.info(
String.format("Message %s was already processed. Will delete message.", message.id()));
log.info("Message {} was already processed. Will delete message.", message.id());
return;
}
// Get all comments; filter and sort them to get the original list of
@@ -212,9 +215,7 @@ public class MailProcessor {
}
if (parsedComments.isEmpty()) {
log.warn(
String.format(
"Could not parse any comments from %s. Will delete message.", message.id()));
log.warn("Could not parse any comments from {}. Will delete message.", message.id());
return;
}

View File

@@ -257,9 +257,10 @@ public class CommentSender extends ReplyToChangeSender {
currentGroup.fileData = new PatchFile(repo, patchList, c.key.filename);
} catch (IOException e) {
log.warn(
String.format(
"Cannot load %s from %s in %s",
c.key.filename, patchList.getNewId().name(), projectState.getName()),
"Cannot load {} from {} in {}",
c.key.filename,
patchList.getNewId().name(),
projectState.getName(),
e);
currentGroup.fileData = null;
}
@@ -353,10 +354,10 @@ public class CommentSender extends ReplyToChangeSender {
maxLines = currentFileData.getLineCount(side);
} catch (IOException err) {
// The file could not be read, leave the max as is.
log.warn(String.format("Failed to read file %s on side %d", comment.key.filename, side), err);
log.warn("Failed to read file {} on side {}", comment.key.filename, side, err);
} catch (NoSuchEntityException err) {
// The file could not be read, leave the max as is.
log.warn(String.format("Side %d of file %s didn't exist", side, comment.key.filename), err);
log.warn("Side {} of file {} didn't exist", side, comment.key.filename, err);
}
int startLine = Math.max(1, lineNbr - contextLines + 1);
@@ -405,7 +406,7 @@ public class CommentSender extends ReplyToChangeSender {
try {
return commentsUtil.getPublished(args.db.get(), changeData.notes(), key);
} catch (OrmException e) {
log.warn("Could not find the parent of this comment: " + child.toString());
log.warn("Could not find the parent of this comment: {}", child.toString());
return Optional.empty();
}
}
@@ -619,16 +620,16 @@ public class CommentSender extends ReplyToChangeSender {
return fileInfo.getLine(side, lineNbr);
} catch (IOException err) {
// Default to the empty string if the file cannot be safely read.
log.warn(String.format("Failed to read file on side %d", side), err);
log.warn("Failed to read file on side {}", side, err);
return "";
} catch (IndexOutOfBoundsException err) {
// Default to the empty string if the given line number does not appear
// in the file.
log.debug(String.format("Failed to get line number of file on side %d", side), err);
log.debug("Failed to get line number of file on side {}", side, err);
return "";
} catch (NoSuchEntityException err) {
// Default to the empty string if the side cannot be found.
log.warn(String.format("Side %d of file didn't exist", side), err);
log.warn("Side {} of file didn't exist", side, err);
return "";
}
}

View File

@@ -148,7 +148,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
throw new NoSuchChangeException(changeId);
}
if (changes.size() != 1) {
log.error(String.format("Multiple changes found for %d", changeId.get()));
log.error("Multiple changes found for {}", changeId.get());
throw new NoSuchChangeException(changeId);
}
return changes.get(0).notes();

View File

@@ -129,7 +129,7 @@ public class JarPluginProvider implements ServerPluginProvider {
if (overlay != null) {
Path classes = Paths.get(overlay).resolve(name).resolve("main");
if (Files.isDirectory(classes)) {
log.info(String.format("plugin %s: including %s", name, classes));
log.info("plugin {}: including {}", name, classes);
urls.add(classes.toUri().toURL());
}
}

View File

@@ -164,9 +164,9 @@ public class PluginLoader implements LifecycleListener {
String name = MoreObjects.firstNonNull(getGerritPluginName(tmp), PluginUtil.nameOf(fileName));
if (!originalName.equals(name)) {
log.warn(
String.format(
"Plugin provides its own name: <%s>, use it instead of the input name: <%s>",
name, originalName));
"Plugin provides its own name: <{}>, use it instead of the input name: <{}>",
name,
originalName);
}
String fileExtension = getExtension(fileName);
@@ -175,7 +175,7 @@ public class PluginLoader implements LifecycleListener {
Plugin active = running.get(name);
if (active != null) {
fileName = active.getSrcFile().getFileName().toString();
log.info(String.format("Replacing plugin %s", active.getName()));
log.info("Replacing plugin {}", active.getName());
Path old = pluginsDir.resolve(".last_" + fileName);
Files.deleteIfExists(old);
Files.move(active.getSrcFile(), old);
@@ -186,7 +186,7 @@ public class PluginLoader implements LifecycleListener {
try {
Plugin plugin = runPlugin(name, dst, active);
if (active == null) {
log.info(String.format("Installed plugin %s", plugin.getName()));
log.info("Installed plugin {}", plugin.getName());
}
} catch (PluginInstallException e) {
Files.deleteIfExists(dst);
@@ -202,7 +202,7 @@ public class PluginLoader implements LifecycleListener {
private synchronized void unloadPlugin(Plugin plugin) {
persistentCacheFactory.onStop(plugin);
String name = plugin.getName();
log.info(String.format("Unloading plugin %s, version %s", name, plugin.getVersion()));
log.info("Unloading plugin {}, version {}", name, plugin.getVersion());
plugin.stop(env);
env.onStopPlugin(plugin);
running.remove(name);
@@ -212,7 +212,7 @@ public class PluginLoader implements LifecycleListener {
public void disablePlugins(Set<String> names) {
if (!isRemoteAdminEnabled()) {
log.warn("Remote plugin administration is disabled, ignoring disablePlugins(" + names + ")");
log.warn("Remote plugin administration is disabled, ignoring disablePlugins({})", names);
return;
}
@@ -223,7 +223,7 @@ public class PluginLoader implements LifecycleListener {
continue;
}
log.info(String.format("Disabling plugin %s", active.getName()));
log.info("Disabling plugin {}", active.getName());
Path off =
active.getSrcFile().resolveSibling(active.getSrcFile().getFileName() + ".disabled");
try {
@@ -243,7 +243,7 @@ public class PluginLoader implements LifecycleListener {
disabled.put(name, offPlugin);
} catch (Throwable e) {
// This shouldn't happen, as the plugin was loaded earlier.
log.warn(String.format("Cannot load disabled plugin %s", active.getName()), e.getCause());
log.warn("Cannot load disabled plugin {}", active.getName(), e.getCause());
}
}
cleanInBackground();
@@ -252,7 +252,7 @@ public class PluginLoader implements LifecycleListener {
public void enablePlugins(Set<String> names) throws PluginInstallException {
if (!isRemoteAdminEnabled()) {
log.warn("Remote plugin administration is disabled, ignoring enablePlugins(" + names + ")");
log.warn("Remote plugin administration is disabled, ignoring enablePlugins({})", names);
return;
}
@@ -263,7 +263,7 @@ public class PluginLoader implements LifecycleListener {
continue;
}
log.info(String.format("Enabling plugin %s", name));
log.info("Enabling plugin {}", name);
String n = off.getSrcFile().toFile().getName();
if (n.endsWith(".disabled")) {
n = n.substring(0, n.lastIndexOf('.'));
@@ -272,7 +272,7 @@ public class PluginLoader implements LifecycleListener {
try {
Files.move(off.getSrcFile(), on);
} catch (IOException e) {
log.error("Failed to move plugin " + name + " into place", e);
log.error("Failed to move plugin {} into place", name, e);
continue;
}
disabled.remove(name);
@@ -292,18 +292,16 @@ public class PluginLoader implements LifecycleListener {
};
try (DirectoryStream<Path> files = Files.newDirectoryStream(tempDir, filter)) {
for (Path file : files) {
log.info("Removing stale plugin file: " + file.toFile().getName());
log.info("Removing stale plugin file: {}", file.toFile().getName());
try {
Files.delete(file);
} catch (IOException e) {
log.error(
String.format(
"Failed to remove stale plugin file %s: %s",
file.toFile().getName(), e.getMessage()));
"Failed to remove stale plugin file {}: {}", file.toFile().getName(), e.getMessage());
}
}
} catch (IOException e) {
log.warn("Unable to discover stale plugin files: " + e.getMessage());
log.warn("Unable to discover stale plugin files: {}", e.getMessage());
}
}
@@ -312,14 +310,14 @@ public class PluginLoader implements LifecycleListener {
removeStalePluginFiles();
Path absolutePath = pluginsDir.toAbsolutePath();
if (!Files.exists(absolutePath)) {
log.info(absolutePath + " does not exist; creating");
log.info("{} does not exist; creating", absolutePath);
try {
Files.createDirectories(absolutePath);
} catch (IOException e) {
log.error(String.format("Failed to create %s: %s", absolutePath, e.getMessage()));
log.error("Failed to create {}: {}", absolutePath, e.getMessage());
}
}
log.info("Loading plugins from " + absolutePath);
log.info("Loading plugins from {}", absolutePath);
srvInfoImpl.state = ServerInformation.State.STARTUP;
rescan();
srvInfoImpl.state = ServerInformation.State.RUNNING;
@@ -368,13 +366,11 @@ public class PluginLoader implements LifecycleListener {
for (Plugin active : reload) {
String name = active.getName();
try {
log.info(String.format("Reloading plugin %s", name));
log.info("Reloading plugin {}", name);
Plugin newPlugin = runPlugin(name, active.getSrcFile(), active);
log.info(
String.format(
"Reloaded plugin %s, version %s", newPlugin.getName(), newPlugin.getVersion()));
log.info("Reloaded plugin {}, version {}", newPlugin.getName(), newPlugin.getVersion());
} catch (PluginInstallException e) {
log.warn(String.format("Cannot reload plugin %s", name), e.getCause());
log.warn("Cannot reload plugin {}", name, e.getCause());
throw e;
}
}
@@ -412,21 +408,20 @@ public class PluginLoader implements LifecycleListener {
}
if (active != null) {
log.info(String.format("Reloading plugin %s", active.getName()));
log.info("Reloading plugin {}", active.getName());
}
try {
Plugin loadedPlugin = runPlugin(name, path, active);
if (!loadedPlugin.isDisabled()) {
log.info(
String.format(
"%s plugin %s, version %s",
active == null ? "Loaded" : "Reloaded",
loadedPlugin.getName(),
loadedPlugin.getVersion()));
"{} plugin {}, version {}",
active == null ? "Loaded" : "Reloaded",
loadedPlugin.getName(),
loadedPlugin.getVersion());
}
} catch (PluginInstallException e) {
log.warn(String.format("Cannot load plugin %s", name), e.getCause());
log.warn("Cannot load plugin {}", name, e.getCause());
}
}
@@ -655,18 +650,19 @@ public class PluginLoader implements LifecycleListener {
Collection<Path> elementsToAdd = new ArrayList<>();
for (Path loser : Iterables.skip(enabled, 1)) {
log.warn(
String.format(
"Plugin <%s> was disabled, because"
+ " another plugin <%s>"
+ " with the same name <%s> already exists",
loser, winner, plugin));
"Plugin <{}> was disabled, because"
+ " another plugin <{}>"
+ " with the same name <{}> already exists",
loser,
winner,
plugin);
Path disabledPlugin = Paths.get(loser + ".disabled");
elementsToAdd.add(disabledPlugin);
elementsToRemove.add(loser);
try {
Files.move(loser, disabledPlugin);
} catch (IOException e) {
log.warn("Failed to fully disable plugin " + loser, e);
log.warn("Failed to fully disable plugin {}", loser, e);
}
}
Iterables.removeAll(files, elementsToRemove);
@@ -679,7 +675,7 @@ public class PluginLoader implements LifecycleListener {
try {
return PluginUtil.listPlugins(pluginsDir);
} catch (IOException e) {
log.error("Cannot list " + pluginsDir.toAbsolutePath(), e);
log.error("Cannot list {}", pluginsDir.toAbsolutePath(), e);
return ImmutableList.of();
}
}

View File

@@ -185,7 +185,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
throw new ResourceConflictException(
"Cannot update " + projectName + ": " + e.getCause().getMessage());
}
log.warn(String.format("Failed to update config of project %s.", projectName), e);
log.warn("Failed to update config of project {}.", projectName, e);
throw new ResourceConflictException("Cannot update " + projectName);
}
@@ -220,9 +220,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
ProjectConfigEntry projectConfigEntry = pluginConfigEntries.get(pluginName, v.getKey());
if (projectConfigEntry != null) {
if (!isValidParameterName(v.getKey())) {
log.warn(
String.format(
"Parameter name '%s' must match '^[a-zA-Z0-9]+[a-zA-Z0-9-]*$'", v.getKey()));
log.warn("Parameter name '{}' must match '^[a-zA-Z0-9]+[a-zA-Z0-9-]*$'", v.getKey());
continue;
}
String oldValue = cfg.getString(v.getKey());
@@ -271,9 +269,9 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
break;
default:
log.warn(
String.format(
"The type '%s' of parameter '%s' is not supported.",
projectConfigEntry.getType().name(), v.getKey()));
"The type '{}' of parameter '{}' is not supported.",
projectConfigEntry.getType().name(),
v.getKey());
}
} catch (NumberFormatException ex) {
throw new BadRequestException(