Do not fail when invalid commentlinks are configured in gerrit.config
Commentlinks are not critical for running Gerrit, just log a warning for invalid commentlinks, but do not fail. Change-Id: Ia67da42ee3f5db1d128d57f276daf3f1d0bba0b8 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
		
				
					committed by
					
						
						David Pursehouse
					
				
			
			
				
	
			
			
			
						parent
						
							271ee3fab2
						
					
				
				
					commit
					8f87b40905
				
			@@ -20,14 +20,18 @@ import com.google.gerrit.server.config.GerritServerConfig;
 | 
			
		||||
import com.google.gerrit.server.git.ProjectConfig;
 | 
			
		||||
import com.google.inject.Inject;
 | 
			
		||||
import com.google.inject.Provider;
 | 
			
		||||
import com.google.inject.ProvisionException;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.jgit.lib.Config;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
public class CommentLinkProvider implements Provider<List<CommentLinkInfo>> {
 | 
			
		||||
  private static final Logger log =
 | 
			
		||||
      LoggerFactory.getLogger(CommentLinkProvider.class);
 | 
			
		||||
 | 
			
		||||
  private final Config cfg;
 | 
			
		||||
 | 
			
		||||
  @Inject
 | 
			
		||||
@@ -41,12 +45,16 @@ public class CommentLinkProvider implements Provider<List<CommentLinkInfo>> {
 | 
			
		||||
    List<CommentLinkInfo> cls =
 | 
			
		||||
        Lists.newArrayListWithCapacity(subsections.size());
 | 
			
		||||
    for (String name : subsections) {
 | 
			
		||||
      try {
 | 
			
		||||
        CommentLinkInfo cl = ProjectConfig.buildCommentLink(cfg, name, true);
 | 
			
		||||
        if (cl.isOverrideOnly()) {
 | 
			
		||||
        throw new ProvisionException(
 | 
			
		||||
            "commentlink " + name + " empty except for \"enabled\"");
 | 
			
		||||
          log.warn("commentlink " + name + " empty except for \"enabled\"");
 | 
			
		||||
          continue;
 | 
			
		||||
        }
 | 
			
		||||
        cls.add(cl);
 | 
			
		||||
      } catch (IllegalArgumentException e) {
 | 
			
		||||
        log.warn("invalid commentlink: " + e.getMessage());
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return ImmutableList.copyOf(cls);
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user