Use Logger's built-in string formatting where possible
Change-Id: Ie1d03cbd17660a777a15961333dbd8c7fbd2e453
This commit is contained in:
		@@ -190,7 +190,7 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
 | 
				
			|||||||
      try {
 | 
					      try {
 | 
				
			||||||
        filter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
 | 
					        filter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
 | 
				
			||||||
      } catch (RuntimeException e) {
 | 
					      } catch (RuntimeException e) {
 | 
				
			||||||
        log.warn(String.format("Plugin %s cannot load GuiceFilter", name), e);
 | 
					        log.warn("Plugin {} cannot load GuiceFilter", name, e);
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -198,7 +198,7 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
 | 
				
			|||||||
        ServletContext ctx = PluginServletContext.create(plugin, wrapper.getFullPath(name));
 | 
					        ServletContext ctx = PluginServletContext.create(plugin, wrapper.getFullPath(name));
 | 
				
			||||||
        filter.init(new WrappedFilterConfig(ctx));
 | 
					        filter.init(new WrappedFilterConfig(ctx));
 | 
				
			||||||
      } catch (ServletException e) {
 | 
					      } 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;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -429,10 +429,11 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
 | 
				
			|||||||
              && size.isPresent()) {
 | 
					              && size.isPresent()) {
 | 
				
			||||||
            if (size.get() <= 0 || size.get() > SMALL_RESOURCE) {
 | 
					            if (size.get() <= 0 || size.get() > SMALL_RESOURCE) {
 | 
				
			||||||
              log.warn(
 | 
					              log.warn(
 | 
				
			||||||
                  String.format(
 | 
					                  "Plugin {}: {} omitted from document index. Size {} out of range (0,{}).",
 | 
				
			||||||
                      "Plugin %s: %s omitted from document index. "
 | 
					                  pluginName,
 | 
				
			||||||
                          + "Size %d out of range (0,%d).",
 | 
					                  name.substring(prefix.length()),
 | 
				
			||||||
                      pluginName, name.substring(prefix.length()), size.get(), SMALL_RESOURCE));
 | 
					                  size.get(),
 | 
				
			||||||
 | 
					                  SMALL_RESOURCE);
 | 
				
			||||||
              return false;
 | 
					              return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
@@ -455,9 +456,9 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
 | 
				
			|||||||
          about = entry;
 | 
					          about = entry;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          log.warn(
 | 
					          log.warn(
 | 
				
			||||||
              String.format(
 | 
					              "Plugin {}: Multiple 'about' documents found; using {}",
 | 
				
			||||||
                  "Plugin %s: Multiple 'about' documents found; using %s",
 | 
					              pluginName,
 | 
				
			||||||
                  pluginName, about.getName().substring(prefix.length())));
 | 
					              about.getName().substring(prefix.length()));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        docs.add(entry);
 | 
					        docs.add(entry);
 | 
				
			||||||
@@ -731,9 +732,7 @@ class HttpPluginServlet extends HttpServlet implements StartPluginListener, Relo
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        return def;
 | 
					        return def;
 | 
				
			||||||
      } catch (IOException e) {
 | 
					      } catch (IOException e) {
 | 
				
			||||||
        log.warn(
 | 
					        log.warn("Error getting {} for plugin {}, using default", attr, plugin.getName(), e);
 | 
				
			||||||
            String.format("Error getting %s for plugin %s, using default", attr, plugin.getName()),
 | 
					 | 
				
			||||||
            e);
 | 
					 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -139,7 +139,7 @@ public class LfsPluginServlet extends HttpServlet
 | 
				
			|||||||
      try {
 | 
					      try {
 | 
				
			||||||
        guiceFilter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
 | 
					        guiceFilter = plugin.getHttpInjector().getInstance(GuiceFilter.class);
 | 
				
			||||||
      } catch (RuntimeException e) {
 | 
					      } catch (RuntimeException e) {
 | 
				
			||||||
        log.warn(String.format("Plugin %s cannot load GuiceFilter", name), e);
 | 
					        log.warn("Plugin {} cannot load GuiceFilter", name, e);
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -147,7 +147,7 @@ public class LfsPluginServlet extends HttpServlet
 | 
				
			|||||||
        ServletContext ctx = PluginServletContext.create(plugin, "/");
 | 
					        ServletContext ctx = PluginServletContext.create(plugin, "/");
 | 
				
			||||||
        guiceFilter.init(new WrappedFilterConfig(ctx));
 | 
					        guiceFilter.init(new WrappedFilterConfig(ctx));
 | 
				
			||||||
      } catch (ServletException e) {
 | 
					      } 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;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -155,7 +155,7 @@ class PluginServletContext {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void log(String msg, Throwable reason) {
 | 
					    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
 | 
					    @Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -161,7 +161,7 @@ public abstract class ResourceServlet extends HttpServlet {
 | 
				
			|||||||
        r = cache.get(p, newLoader(p));
 | 
					        r = cache.get(p, newLoader(p));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } catch (ExecutionException e) {
 | 
					    } catch (ExecutionException e) {
 | 
				
			||||||
      log.warn("Cannot load static resource " + req.getPathInfo(), e);
 | 
					      log.warn("Cannot load static resource {}", req.getPathInfo(), e);
 | 
				
			||||||
      CacheHeaders.setNotCacheable(rsp);
 | 
					      CacheHeaders.setNotCacheable(rsp);
 | 
				
			||||||
      rsp.setStatus(SC_INTERNAL_SERVER_ERROR);
 | 
					      rsp.setStatus(SC_INTERNAL_SERVER_ERROR);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
@@ -214,12 +214,12 @@ public abstract class ResourceServlet extends HttpServlet {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      Path p = getResourcePath(name);
 | 
					      Path p = getResourcePath(name);
 | 
				
			||||||
      if (p == null) {
 | 
					      if (p == null) {
 | 
				
			||||||
        log.warn(String.format("Path doesn't exist %s", name));
 | 
					        log.warn("Path doesn't exist {}", name);
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return cache.get(p, newLoader(p));
 | 
					      return cache.get(p, newLoader(p));
 | 
				
			||||||
    } catch (ExecutionException | IOException e) {
 | 
					    } 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;
 | 
					      return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1094,7 +1094,7 @@ public class RestApiServlet extends HttpServlet {
 | 
				
			|||||||
    if (!Strings.isNullOrEmpty(req.getQueryString())) {
 | 
					    if (!Strings.isNullOrEmpty(req.getQueryString())) {
 | 
				
			||||||
      uri += "?" + 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()) {
 | 
					    if (!res.isCommitted()) {
 | 
				
			||||||
      res.reset();
 | 
					      res.reset();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,7 +68,7 @@ public class SwitchSecureStore extends SiteProgram {
 | 
				
			|||||||
    SitePaths sitePaths = new SitePaths(getSitePath());
 | 
					    SitePaths sitePaths = new SitePaths(getSitePath());
 | 
				
			||||||
    Path newSecureStorePath = Paths.get(newSecureStoreLib);
 | 
					    Path newSecureStorePath = Paths.get(newSecureStoreLib);
 | 
				
			||||||
    if (!Files.exists(newSecureStorePath)) {
 | 
					    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;
 | 
					      return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -77,8 +77,7 @@ public class SwitchSecureStore extends SiteProgram {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (currentSecureStoreName.equals(newSecureStore)) {
 | 
					    if (currentSecureStoreName.equals(newSecureStore)) {
 | 
				
			||||||
      log.error(
 | 
					      log.error(
 | 
				
			||||||
          "Old and new SecureStore implementation names "
 | 
					          "Old and new SecureStore implementation names are the same. Migration will not work");
 | 
				
			||||||
              + "are the same. Migration will not work");
 | 
					 | 
				
			||||||
      return -1;
 | 
					      return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ class HiddenErrorHandler extends ErrorHandler {
 | 
				
			|||||||
      if (!Strings.isNullOrEmpty(req.getQueryString())) {
 | 
					      if (!Strings.isNullOrEmpty(req.getQueryString())) {
 | 
				
			||||||
        uri += "?" + 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);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,7 +49,7 @@ public class WebLinks {
 | 
				
			|||||||
        if (link == null) {
 | 
					        if (link == null) {
 | 
				
			||||||
          return false;
 | 
					          return false;
 | 
				
			||||||
        } else if (Strings.isNullOrEmpty(link.name) || Strings.isNullOrEmpty(link.url)) {
 | 
					        } 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 false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
@@ -60,7 +60,7 @@ public class WebLinks {
 | 
				
			|||||||
        if (link == null) {
 | 
					        if (link == null) {
 | 
				
			||||||
          return false;
 | 
					          return false;
 | 
				
			||||||
        } else if (Strings.isNullOrEmpty(link.name) || Strings.isNullOrEmpty(link.url)) {
 | 
					        } 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 false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,7 +92,7 @@ public class GroupCacheImpl implements GroupCache {
 | 
				
			|||||||
      Optional<AccountGroup> g = byId.get(groupId);
 | 
					      Optional<AccountGroup> g = byId.get(groupId);
 | 
				
			||||||
      return g.isPresent() ? g.get() : missing(groupId);
 | 
					      return g.isPresent() ? g.get() : missing(groupId);
 | 
				
			||||||
    } catch (ExecutionException e) {
 | 
					    } catch (ExecutionException e) {
 | 
				
			||||||
      log.warn("Cannot load group " + groupId, e);
 | 
					      log.warn("Cannot load group {}", groupId, e);
 | 
				
			||||||
      return missing(groupId);
 | 
					      return missing(groupId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -131,7 +131,7 @@ public class GroupCacheImpl implements GroupCache {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      return byName.get(name.get()).orElse(null);
 | 
					      return byName.get(name.get()).orElse(null);
 | 
				
			||||||
    } catch (ExecutionException e) {
 | 
					    } catch (ExecutionException e) {
 | 
				
			||||||
      log.warn(String.format("Cannot lookup group %s by name", name.get()), e);
 | 
					      log.warn("Cannot lookup group {} by name", name.get(), e);
 | 
				
			||||||
      return null;
 | 
					      return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -144,7 +144,7 @@ public class GroupCacheImpl implements GroupCache {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      return byUUID.get(uuid.get()).orElse(null);
 | 
					      return byUUID.get(uuid.get()).orElse(null);
 | 
				
			||||||
    } catch (ExecutionException e) {
 | 
					    } catch (ExecutionException e) {
 | 
				
			||||||
      log.warn(String.format("Cannot lookup group %s by uuid", uuid.get()), e);
 | 
					      log.warn("Cannot lookup group {} by uuid", uuid.get(), e);
 | 
				
			||||||
      return null;
 | 
					      return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -126,7 +126,7 @@ public class LdapGroupBackend implements GroupBackend {
 | 
				
			|||||||
          return null;
 | 
					          return null;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } catch (ExecutionException e) {
 | 
					      } 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;
 | 
					        return null;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -65,7 +65,7 @@ class LdapGroupMembership implements GroupMembership {
 | 
				
			|||||||
      try {
 | 
					      try {
 | 
				
			||||||
        membership = new ListGroupMembership(membershipCache.get(id));
 | 
					        membership = new ListGroupMembership(membershipCache.get(id));
 | 
				
			||||||
      } catch (ExecutionException e) {
 | 
					      } 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;
 | 
					        membership = GroupMembership.EMPTY;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -313,7 +313,7 @@ class LdapRealm extends AbstractRealm {
 | 
				
			|||||||
      Optional<Account.Id> id = usernameCache.get(accountName);
 | 
					      Optional<Account.Id> id = usernameCache.get(accountName);
 | 
				
			||||||
      return id != null ? id.orElse(null) : null;
 | 
					      return id != null ? id.orElse(null) : null;
 | 
				
			||||||
    } catch (ExecutionException e) {
 | 
					    } 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;
 | 
					      return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -96,7 +96,7 @@ public class AbandonUtil {
 | 
				
			|||||||
          log.error(msg.toString(), e);
 | 
					          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) {
 | 
					    } catch (QueryParseException | OrmException e) {
 | 
				
			||||||
      log.error("Failed to query inactive open changes for auto-abandoning.", e);
 | 
					      log.error("Failed to query inactive open changes for auto-abandoning.", e);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -150,7 +150,7 @@ 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) {
 | 
				
			||||||
      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.url = getChangeUrl(change);
 | 
				
			||||||
    a.owner = asAccountAttribute(change.getOwner());
 | 
					    a.owner = asAccountAttribute(change.getOwner());
 | 
				
			||||||
@@ -498,9 +498,9 @@ public class EventFactory {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      p.kind = changeKindCache.getChangeKind(db, change, patchSet);
 | 
					      p.kind = changeKindCache.getChangeKind(db, change, patchSet);
 | 
				
			||||||
    } catch (IOException e) {
 | 
					    } catch (IOException e) {
 | 
				
			||||||
      log.error("Cannot load patch set data for " + patchSet.getId(), e);
 | 
					      log.error("Cannot load patch set data for {}", patchSet.getId(), e);
 | 
				
			||||||
    } catch (PatchListNotAvailableException e) {
 | 
					    } 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;
 | 
					    return p;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -118,9 +118,9 @@ public class EventUtil {
 | 
				
			|||||||
  public void logEventListenerError(Object event, Object listener, Exception error) {
 | 
					  public void logEventListenerError(Object event, Object listener, Exception error) {
 | 
				
			||||||
    if (log.isDebugEnabled()) {
 | 
					    if (log.isDebugEnabled()) {
 | 
				
			||||||
      log.debug(
 | 
					      log.debug(
 | 
				
			||||||
          String.format(
 | 
					          "Error in event listener {} for event {}",
 | 
				
			||||||
              "Error in event listener %s for event %s",
 | 
					          listener.getClass().getName(),
 | 
				
			||||||
              listener.getClass().getName(), event.getClass().getName()),
 | 
					          event.getClass().getName(),
 | 
				
			||||||
          error);
 | 
					          error);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      log.warn(
 | 
					      log.warn(
 | 
				
			||||||
@@ -133,7 +133,7 @@ public class EventUtil {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  public static void logEventListenerError(Object listener, Exception error) {
 | 
					  public static void logEventListenerError(Object listener, Exception error) {
 | 
				
			||||||
    if (log.isDebugEnabled()) {
 | 
					    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 {
 | 
					    } else {
 | 
				
			||||||
      log.warn("Error in event listener {}: {}", listener.getClass().getName(), error.getMessage());
 | 
					      log.warn("Error in event listener {}: {}", listener.getClass().getName(), error.getMessage());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,7 @@ public class GarbageCollectionRunner implements Runnable {
 | 
				
			|||||||
      if (delay == MISSING_CONFIG && interval == MISSING_CONFIG) {
 | 
					      if (delay == MISSING_CONFIG && interval == MISSING_CONFIG) {
 | 
				
			||||||
        log.info("Ignoring missing gc schedule configuration");
 | 
					        log.info("Ignoring missing gc schedule configuration");
 | 
				
			||||||
      } else if (delay < 0 || interval <= 0) {
 | 
					      } 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 {
 | 
					      } else {
 | 
				
			||||||
        @SuppressWarnings("unused")
 | 
					        @SuppressWarnings("unused")
 | 
				
			||||||
        Future<?> possiblyIgnoredError =
 | 
					        Future<?> possiblyIgnoredError =
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -100,7 +100,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
 | 
				
			|||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          desc = String.format("%d", limit);
 | 
					          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.setStreamFileThreshold(limit);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      cfg.install();
 | 
					      cfg.install();
 | 
				
			||||||
@@ -226,9 +226,7 @@ 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()) {
 | 
				
			||||||
        log.error(
 | 
					        log.error("Failed to create ref log for {} in repository {}", RefNames.REFS_CONFIG, name);
 | 
				
			||||||
            String.format(
 | 
					 | 
				
			||||||
                "Failed to create ref log for %s in repository %s", RefNames.REFS_CONFIG, name));
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      onCreateProject(name);
 | 
					      onCreateProject(name);
 | 
				
			||||||
@@ -304,7 +302,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
 | 
				
			|||||||
          Integer.MAX_VALUE,
 | 
					          Integer.MAX_VALUE,
 | 
				
			||||||
          visitor);
 | 
					          visitor);
 | 
				
			||||||
    } catch (IOException e) {
 | 
					    } catch (IOException e) {
 | 
				
			||||||
      log.error("Error walking repository tree " + visitor.startFolder.toAbsolutePath(), e);
 | 
					      log.error("Error walking repository tree {}", visitor.startFolder.toAbsolutePath(), e);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -359,7 +357,7 @@ public class LocalDiskRepositoryManager implements GitRepositoryManager {
 | 
				
			|||||||
      Project.NameKey nameKey = getProjectName(startFolder, p);
 | 
					      Project.NameKey nameKey = getProjectName(startFolder, p);
 | 
				
			||||||
      if (getBasePath(nameKey).equals(startFolder)) {
 | 
					      if (getBasePath(nameKey).equals(startFolder)) {
 | 
				
			||||||
        if (isUnreasonableName(nameKey)) {
 | 
					        if (isUnreasonableName(nameKey)) {
 | 
				
			||||||
          log.warn("Ignoring unreasonably named repository " + p.toAbsolutePath());
 | 
					          log.warn("Ignoring unreasonably named repository {}", p.toAbsolutePath());
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
          found.add(nameKey);
 | 
					          found.add(nameKey);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -650,7 +650,7 @@ public class ReceiveCommits {
 | 
				
			|||||||
          try {
 | 
					          try {
 | 
				
			||||||
            repo.setGitwebDescription(ps.getProject().getDescription());
 | 
					            repo.setGitwebDescription(ps.getProject().getDescription());
 | 
				
			||||||
          } catch (IOException e) {
 | 
					          } catch (IOException e) {
 | 
				
			||||||
            log.warn("cannot update description of " + project.getName(), e);
 | 
					            log.warn("cannot update description of {}", project.getName(), e);
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -186,7 +186,7 @@ public class Schema<T> {
 | 
				
			|||||||
                try {
 | 
					                try {
 | 
				
			||||||
                  v = f.get(obj, fillArgs);
 | 
					                  v = f.get(obj, fillArgs);
 | 
				
			||||||
                } catch (OrmException e) {
 | 
					                } 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;
 | 
					                  return null;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (v == null) {
 | 
					                if (v == null) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -206,7 +206,7 @@ public class StalenessChecker {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    } catch (IOException e) {
 | 
					    } 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;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -128,9 +128,10 @@ public class MailProcessor {
 | 
				
			|||||||
    for (DynamicMap.Entry<MailFilter> filter : mailFilters) {
 | 
					    for (DynamicMap.Entry<MailFilter> filter : mailFilters) {
 | 
				
			||||||
      if (!filter.getProvider().get().shouldProcessMessage(message)) {
 | 
					      if (!filter.getProvider().get().shouldProcessMessage(message)) {
 | 
				
			||||||
        log.warn(
 | 
					        log.warn(
 | 
				
			||||||
            String.format(
 | 
					            "Message {} filtered by plugin {} {}. Will delete message.",
 | 
				
			||||||
                "Message %s filtered by plugin %s %s. Will delete message.",
 | 
					            message.id(),
 | 
				
			||||||
                message.id(), filter.getPluginName(), filter.getExportName()));
 | 
					            filter.getPluginName(),
 | 
				
			||||||
 | 
					            filter.getExportName());
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -138,23 +139,24 @@ public class MailProcessor {
 | 
				
			|||||||
    MailMetadata metadata = MetadataParser.parse(message);
 | 
					    MailMetadata metadata = MetadataParser.parse(message);
 | 
				
			||||||
    if (!metadata.hasRequiredFields()) {
 | 
					    if (!metadata.hasRequiredFields()) {
 | 
				
			||||||
      log.error(
 | 
					      log.error(
 | 
				
			||||||
          String.format(
 | 
					          "Message {} is missing required metadata, have {}. Will delete message.",
 | 
				
			||||||
              "Message %s is missing required metadata, have %s. Will delete message.",
 | 
					          message.id(),
 | 
				
			||||||
              message.id(), metadata));
 | 
					          metadata);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Set<Account.Id> accounts = accountByEmailCache.get(metadata.author);
 | 
					    Set<Account.Id> accounts = accountByEmailCache.get(metadata.author);
 | 
				
			||||||
    if (accounts.size() != 1) {
 | 
					    if (accounts.size() != 1) {
 | 
				
			||||||
      log.error(
 | 
					      log.error(
 | 
				
			||||||
          String.format(
 | 
					          "Address {} could not be matched to a unique account. It was matched to {}."
 | 
				
			||||||
              "Address %s could not be matched to a unique account. It was matched to %s. Will delete message.",
 | 
					              + " Will delete message.",
 | 
				
			||||||
              metadata.author, accounts));
 | 
					          metadata.author,
 | 
				
			||||||
 | 
					          accounts);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    Account.Id account = accounts.iterator().next();
 | 
					    Account.Id account = accounts.iterator().next();
 | 
				
			||||||
    if (!accountCache.get(account).getAccount().isActive()) {
 | 
					    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;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -163,14 +165,16 @@ public class MailProcessor {
 | 
				
			|||||||
          queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
 | 
					          queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
 | 
				
			||||||
      if (changeDataList.size() != 1) {
 | 
					      if (changeDataList.size() != 1) {
 | 
				
			||||||
        log.error(
 | 
					        log.error(
 | 
				
			||||||
            String.format(
 | 
					            "Message {} references unique change {}, but there are {} matching changes in "
 | 
				
			||||||
                "Message %s references unique change %s, but there are %d matching changes in the index. Will delete message.",
 | 
					                + "the index. Will delete message.",
 | 
				
			||||||
                message.id(), metadata.changeNumber, changeDataList.size()));
 | 
					            message.id(),
 | 
				
			||||||
 | 
					            metadata.changeNumber,
 | 
				
			||||||
 | 
					            changeDataList.size());
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      ChangeData cd = changeDataList.get(0);
 | 
					      ChangeData cd = changeDataList.get(0);
 | 
				
			||||||
      if (existingMessageIds(cd).contains(message.id())) {
 | 
					      if (existingMessageIds(cd).contains(message.id())) {
 | 
				
			||||||
        log.info("Message " + message.id() + " was already processed. Will delete message.");
 | 
					        log.info("Message {} was already processed. Will delete message.", message.id());
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      // Get all comments; filter and sort them to get the original list of
 | 
					      // Get all comments; filter and sort them to get the original list of
 | 
				
			||||||
@@ -193,7 +197,7 @@ public class MailProcessor {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (parsedComments.isEmpty()) {
 | 
					      if (parsedComments.isEmpty()) {
 | 
				
			||||||
        log.warn("Could not parse any comments from " + message.id() + ". Will delete message.");
 | 
					        log.warn("Could not parse any comments from {}. Will delete message.", message.id());
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -254,11 +254,10 @@ public class CommentSender extends ReplyToChangeSender {
 | 
				
			|||||||
            currentGroup.fileData = new PatchFile(repo, patchList, c.key.filename);
 | 
					            currentGroup.fileData = new PatchFile(repo, patchList, c.key.filename);
 | 
				
			||||||
          } catch (IOException e) {
 | 
					          } catch (IOException e) {
 | 
				
			||||||
            log.warn(
 | 
					            log.warn(
 | 
				
			||||||
                String.format(
 | 
					                "Cannot load {} from {} in {}",
 | 
				
			||||||
                    "Cannot load %s from %s in %s",
 | 
					                c.key.filename,
 | 
				
			||||||
                    c.key.filename,
 | 
					                patchList.getNewId().name(),
 | 
				
			||||||
                    patchList.getNewId().name(),
 | 
					                projectState.getProject().getName(),
 | 
				
			||||||
                    projectState.getProject().getName()),
 | 
					 | 
				
			||||||
                e);
 | 
					                e);
 | 
				
			||||||
            currentGroup.fileData = null;
 | 
					            currentGroup.fileData = null;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
@@ -352,10 +351,10 @@ public class CommentSender extends ReplyToChangeSender {
 | 
				
			|||||||
      maxLines = currentFileData.getLineCount(side);
 | 
					      maxLines = currentFileData.getLineCount(side);
 | 
				
			||||||
    } catch (IOException err) {
 | 
					    } catch (IOException err) {
 | 
				
			||||||
      // The file could not be read, leave the max as is.
 | 
					      // 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) {
 | 
					    } catch (NoSuchEntityException err) {
 | 
				
			||||||
      // The file could not be read, leave the max as is.
 | 
					      // 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);
 | 
					    int startLine = Math.max(1, lineNbr - contextLines + 1);
 | 
				
			||||||
@@ -404,7 +403,7 @@ public class CommentSender extends ReplyToChangeSender {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      return commentsUtil.get(args.db.get(), changeData.notes(), key);
 | 
					      return commentsUtil.get(args.db.get(), changeData.notes(), key);
 | 
				
			||||||
    } catch (OrmException e) {
 | 
					    } 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();
 | 
					      return Optional.empty();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -595,16 +594,16 @@ public class CommentSender extends ReplyToChangeSender {
 | 
				
			|||||||
      return fileInfo.getLine(side, lineNbr);
 | 
					      return fileInfo.getLine(side, lineNbr);
 | 
				
			||||||
    } catch (IOException err) {
 | 
					    } catch (IOException err) {
 | 
				
			||||||
      // Default to the empty string if the file cannot be safely read.
 | 
					      // 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 "";
 | 
					      return "";
 | 
				
			||||||
    } catch (IndexOutOfBoundsException err) {
 | 
					    } catch (IndexOutOfBoundsException err) {
 | 
				
			||||||
      // Default to the empty string if the given line number does not appear
 | 
					      // Default to the empty string if the given line number does not appear
 | 
				
			||||||
      // in the file.
 | 
					      // 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 "";
 | 
					      return "";
 | 
				
			||||||
    } catch (NoSuchEntityException err) {
 | 
					    } catch (NoSuchEntityException err) {
 | 
				
			||||||
      // Default to the empty string if the side cannot be found.
 | 
					      // 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 "";
 | 
					      return "";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,7 +140,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
 | 
				
			|||||||
        throw new NoSuchChangeException(changeId);
 | 
					        throw new NoSuchChangeException(changeId);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (changes.size() != 1) {
 | 
					      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);
 | 
					        throw new NoSuchChangeException(changeId);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      return changes.get(0).notes();
 | 
					      return changes.get(0).notes();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,7 +131,7 @@ public class JarPluginProvider implements ServerPluginProvider {
 | 
				
			|||||||
      if (overlay != null) {
 | 
					      if (overlay != null) {
 | 
				
			||||||
        Path classes = Paths.get(overlay).resolve(name).resolve("main");
 | 
					        Path classes = Paths.get(overlay).resolve(name).resolve("main");
 | 
				
			||||||
        if (Files.isDirectory(classes)) {
 | 
					        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());
 | 
					          urls.add(classes.toUri().toURL());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -195,9 +195,9 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
    String name = MoreObjects.firstNonNull(getGerritPluginName(tmp), nameOf(fileName));
 | 
					    String name = MoreObjects.firstNonNull(getGerritPluginName(tmp), nameOf(fileName));
 | 
				
			||||||
    if (!originalName.equals(name)) {
 | 
					    if (!originalName.equals(name)) {
 | 
				
			||||||
      log.warn(
 | 
					      log.warn(
 | 
				
			||||||
          String.format(
 | 
					          "Plugin provides its own name: <{}>, use it instead of the input name: <{}>",
 | 
				
			||||||
              "Plugin provides its own name: <%s>, use it instead of the input name: <%s>",
 | 
					          name,
 | 
				
			||||||
              name, originalName));
 | 
					          originalName);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    String fileExtension = getExtension(fileName);
 | 
					    String fileExtension = getExtension(fileName);
 | 
				
			||||||
@@ -206,7 +206,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
      Plugin active = running.get(name);
 | 
					      Plugin active = running.get(name);
 | 
				
			||||||
      if (active != null) {
 | 
					      if (active != null) {
 | 
				
			||||||
        fileName = active.getSrcFile().getFileName().toString();
 | 
					        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);
 | 
					        Path old = pluginsDir.resolve(".last_" + fileName);
 | 
				
			||||||
        Files.deleteIfExists(old);
 | 
					        Files.deleteIfExists(old);
 | 
				
			||||||
        Files.move(active.getSrcFile(), old);
 | 
					        Files.move(active.getSrcFile(), old);
 | 
				
			||||||
@@ -217,7 +217,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
      try {
 | 
					      try {
 | 
				
			||||||
        Plugin plugin = runPlugin(name, dst, active);
 | 
					        Plugin plugin = runPlugin(name, dst, active);
 | 
				
			||||||
        if (active == null) {
 | 
					        if (active == null) {
 | 
				
			||||||
          log.info(String.format("Installed plugin %s", plugin.getName()));
 | 
					          log.info("Installed plugin {}", plugin.getName());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } catch (PluginInstallException e) {
 | 
					      } catch (PluginInstallException e) {
 | 
				
			||||||
        Files.deleteIfExists(dst);
 | 
					        Files.deleteIfExists(dst);
 | 
				
			||||||
@@ -247,7 +247,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
  private synchronized void unloadPlugin(Plugin plugin) {
 | 
					  private synchronized void unloadPlugin(Plugin plugin) {
 | 
				
			||||||
    persistentCacheFactory.onStop(plugin);
 | 
					    persistentCacheFactory.onStop(plugin);
 | 
				
			||||||
    String name = plugin.getName();
 | 
					    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);
 | 
					    plugin.stop(env);
 | 
				
			||||||
    env.onStopPlugin(plugin);
 | 
					    env.onStopPlugin(plugin);
 | 
				
			||||||
    running.remove(name);
 | 
					    running.remove(name);
 | 
				
			||||||
@@ -257,7 +257,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  public void disablePlugins(Set<String> names) {
 | 
					  public void disablePlugins(Set<String> names) {
 | 
				
			||||||
    if (!isRemoteAdminEnabled()) {
 | 
					    if (!isRemoteAdminEnabled()) {
 | 
				
			||||||
      log.warn("Remote plugin administration is disabled, ignoring disablePlugins(" + names + ")");
 | 
					      log.warn("Remote plugin administration is disabled, ignoring disablePlugins({})", names);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -268,7 +268,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        log.info(String.format("Disabling plugin %s", active.getName()));
 | 
					        log.info("Disabling plugin {}", active.getName());
 | 
				
			||||||
        Path off =
 | 
					        Path off =
 | 
				
			||||||
            active.getSrcFile().resolveSibling(active.getSrcFile().getFileName() + ".disabled");
 | 
					            active.getSrcFile().resolveSibling(active.getSrcFile().getFileName() + ".disabled");
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@@ -288,7 +288,7 @@ 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.
 | 
				
			||||||
          log.warn(String.format("Cannot load disabled plugin %s", active.getName()), e.getCause());
 | 
					          log.warn("Cannot load disabled plugin {}", active.getName(), e.getCause());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      cleanInBackground();
 | 
					      cleanInBackground();
 | 
				
			||||||
@@ -297,7 +297,7 @@ 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()) {
 | 
				
			||||||
      log.warn("Remote plugin administration is disabled, ignoring enablePlugins(" + names + ")");
 | 
					      log.warn("Remote plugin administration is disabled, ignoring enablePlugins({})", names);
 | 
				
			||||||
      return;
 | 
					      return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -308,7 +308,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        log.info(String.format("Enabling plugin %s", name));
 | 
					        log.info("Enabling plugin {}", name);
 | 
				
			||||||
        String n = off.getSrcFile().toFile().getName();
 | 
					        String n = off.getSrcFile().toFile().getName();
 | 
				
			||||||
        if (n.endsWith(".disabled")) {
 | 
					        if (n.endsWith(".disabled")) {
 | 
				
			||||||
          n = n.substring(0, n.lastIndexOf('.'));
 | 
					          n = n.substring(0, n.lastIndexOf('.'));
 | 
				
			||||||
@@ -317,7 +317,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
        try {
 | 
					        try {
 | 
				
			||||||
          Files.move(off.getSrcFile(), on);
 | 
					          Files.move(off.getSrcFile(), on);
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
          log.error("Failed to move plugin " + name + " into place", e);
 | 
					          log.error("Failed to move plugin {} into place", name, e);
 | 
				
			||||||
          continue;
 | 
					          continue;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        disabled.remove(name);
 | 
					        disabled.remove(name);
 | 
				
			||||||
@@ -337,25 +337,23 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
    try (DirectoryStream<Path> files = Files.newDirectoryStream(tempDir, filter)) {
 | 
					    try (DirectoryStream<Path> files = Files.newDirectoryStream(tempDir, filter)) {
 | 
				
			||||||
      for (Path file : files) {
 | 
					      for (Path file : files) {
 | 
				
			||||||
        log.info("Removing stale plugin file: " + file.toFile().getName());
 | 
					        log.info("Removing stale plugin file: {}", file.toFile().getName());
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          Files.delete(file);
 | 
					          Files.delete(file);
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
          log.error(
 | 
					          log.error(
 | 
				
			||||||
              String.format(
 | 
					              "Failed to remove stale plugin file {}: {}", file.toFile().getName(), e.getMessage());
 | 
				
			||||||
                  "Failed to remove stale plugin file %s: %s",
 | 
					 | 
				
			||||||
                  file.toFile().getName(), e.getMessage()));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } catch (IOException e) {
 | 
					    } catch (IOException e) {
 | 
				
			||||||
      log.warn("Unable to discover stale plugin files: " + e.getMessage());
 | 
					      log.warn("Unable to discover stale plugin files: {}", e.getMessage());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
  public synchronized void start() {
 | 
					  public synchronized void start() {
 | 
				
			||||||
    removeStalePluginFiles();
 | 
					    removeStalePluginFiles();
 | 
				
			||||||
    log.info("Loading plugins from " + pluginsDir.toAbsolutePath());
 | 
					    log.info("Loading plugins from {}", pluginsDir.toAbsolutePath());
 | 
				
			||||||
    srvInfoImpl.state = ServerInformation.State.STARTUP;
 | 
					    srvInfoImpl.state = ServerInformation.State.STARTUP;
 | 
				
			||||||
    rescan();
 | 
					    rescan();
 | 
				
			||||||
    srvInfoImpl.state = ServerInformation.State.RUNNING;
 | 
					    srvInfoImpl.state = ServerInformation.State.RUNNING;
 | 
				
			||||||
@@ -404,13 +402,11 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
      for (Plugin active : reload) {
 | 
					      for (Plugin active : reload) {
 | 
				
			||||||
        String name = active.getName();
 | 
					        String name = active.getName();
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          log.info(String.format("Reloading plugin %s", name));
 | 
					          log.info("Reloading plugin {}", name);
 | 
				
			||||||
          Plugin newPlugin = runPlugin(name, active.getSrcFile(), active);
 | 
					          Plugin newPlugin = runPlugin(name, active.getSrcFile(), active);
 | 
				
			||||||
          log.info(
 | 
					          log.info("Reloaded plugin {}, version {}", newPlugin.getName(), newPlugin.getVersion());
 | 
				
			||||||
              String.format(
 | 
					 | 
				
			||||||
                  "Reloaded plugin %s, version %s", newPlugin.getName(), newPlugin.getVersion()));
 | 
					 | 
				
			||||||
        } catch (PluginInstallException e) {
 | 
					        } catch (PluginInstallException e) {
 | 
				
			||||||
          log.warn(String.format("Cannot reload plugin %s", name), e.getCause());
 | 
					          log.warn("Cannot reload plugin {}", name, e.getCause());
 | 
				
			||||||
          throw e;
 | 
					          throw e;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
@@ -448,21 +444,20 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (active != null) {
 | 
					      if (active != null) {
 | 
				
			||||||
        log.info(String.format("Reloading plugin %s", active.getName()));
 | 
					        log.info("Reloading plugin {}", active.getName());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      try {
 | 
					      try {
 | 
				
			||||||
        Plugin loadedPlugin = runPlugin(name, path, active);
 | 
					        Plugin loadedPlugin = runPlugin(name, path, active);
 | 
				
			||||||
        if (!loadedPlugin.isDisabled()) {
 | 
					        if (!loadedPlugin.isDisabled()) {
 | 
				
			||||||
          log.info(
 | 
					          log.info(
 | 
				
			||||||
              String.format(
 | 
					              "{} plugin {}, version {}",
 | 
				
			||||||
                  "%s plugin %s, version %s",
 | 
					              active == null ? "Loaded" : "Reloaded",
 | 
				
			||||||
                  active == null ? "Loaded" : "Reloaded",
 | 
					              loadedPlugin.getName(),
 | 
				
			||||||
                  loadedPlugin.getName(),
 | 
					              loadedPlugin.getVersion());
 | 
				
			||||||
                  loadedPlugin.getVersion()));
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      } catch (PluginInstallException e) {
 | 
					      } catch (PluginInstallException e) {
 | 
				
			||||||
        log.warn(String.format("Cannot load plugin %s", name), e.getCause());
 | 
					        log.warn("Cannot load plugin {}", name, e.getCause());
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -716,18 +711,19 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
      Collection<Path> elementsToAdd = new ArrayList<>();
 | 
					      Collection<Path> elementsToAdd = new ArrayList<>();
 | 
				
			||||||
      for (Path loser : Iterables.skip(enabled, 1)) {
 | 
					      for (Path loser : Iterables.skip(enabled, 1)) {
 | 
				
			||||||
        log.warn(
 | 
					        log.warn(
 | 
				
			||||||
            String.format(
 | 
					            "Plugin <{}> was disabled, because"
 | 
				
			||||||
                "Plugin <%s> was disabled, because"
 | 
					                + " another plugin <{}>"
 | 
				
			||||||
                    + " another plugin <%s>"
 | 
					                + " with the same name <{}> already exists",
 | 
				
			||||||
                    + " with the same name <%s> already exists",
 | 
					            loser,
 | 
				
			||||||
                loser, winner, plugin));
 | 
					            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);
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
          Files.move(loser, disabledPlugin);
 | 
					          Files.move(loser, disabledPlugin);
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } 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);
 | 
					      Iterables.removeAll(files, elementsToRemove);
 | 
				
			||||||
@@ -740,7 +736,7 @@ public class PluginLoader implements LifecycleListener {
 | 
				
			|||||||
    try {
 | 
					    try {
 | 
				
			||||||
      return listPlugins(pluginsDir);
 | 
					      return listPlugins(pluginsDir);
 | 
				
			||||||
    } catch (IOException e) {
 | 
					    } catch (IOException e) {
 | 
				
			||||||
      log.error("Cannot list " + pluginsDir.toAbsolutePath(), e);
 | 
					      log.error("Cannot list {}", pluginsDir.toAbsolutePath(), e);
 | 
				
			||||||
      return ImmutableList.of();
 | 
					      return ImmutableList.of();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -168,7 +168,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
 | 
				
			|||||||
          throw new ResourceConflictException(
 | 
					          throw new ResourceConflictException(
 | 
				
			||||||
              "Cannot update " + projectName + ": " + e.getCause().getMessage());
 | 
					              "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);
 | 
					        throw new ResourceConflictException("Cannot update " + projectName);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -202,9 +202,7 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
 | 
				
			|||||||
        ProjectConfigEntry projectConfigEntry = pluginConfigEntries.get(pluginName, v.getKey());
 | 
					        ProjectConfigEntry projectConfigEntry = pluginConfigEntries.get(pluginName, v.getKey());
 | 
				
			||||||
        if (projectConfigEntry != null) {
 | 
					        if (projectConfigEntry != null) {
 | 
				
			||||||
          if (!isValidParameterName(v.getKey())) {
 | 
					          if (!isValidParameterName(v.getKey())) {
 | 
				
			||||||
            log.warn(
 | 
					            log.warn("Parameter name '{}' must match '^[a-zA-Z0-9]+[a-zA-Z0-9-]*$'", v.getKey());
 | 
				
			||||||
                String.format(
 | 
					 | 
				
			||||||
                    "Parameter name '%s' must match '^[a-zA-Z0-9]+[a-zA-Z0-9-]*$'", v.getKey()));
 | 
					 | 
				
			||||||
            continue;
 | 
					            continue;
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          String oldValue = cfg.getString(v.getKey());
 | 
					          String oldValue = cfg.getString(v.getKey());
 | 
				
			||||||
@@ -253,9 +251,9 @@ public class PutConfig implements RestModifyView<ProjectResource, ConfigInput> {
 | 
				
			|||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                  default:
 | 
					                  default:
 | 
				
			||||||
                    log.warn(
 | 
					                    log.warn(
 | 
				
			||||||
                        String.format(
 | 
					                        "The type '{}' of parameter '{}' is not supported.",
 | 
				
			||||||
                            "The type '%s' of parameter '%s' is not supported.",
 | 
					                        projectConfigEntry.getType().name(),
 | 
				
			||||||
                            projectConfigEntry.getType().name(), v.getKey()));
 | 
					                        v.getKey());
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
              } catch (NumberFormatException ex) {
 | 
					              } catch (NumberFormatException ex) {
 | 
				
			||||||
                throw new BadRequestException(
 | 
					                throw new BadRequestException(
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user