Ignore duplicate log recorder keys
@@ -78,6 +78,9 @@ import org.kohsuke.stapler.interceptor.RequirePOST;
* @author Kohsuke Kawaguchi
*/
public class LogRecorderManager extends AbstractModelObject implements ModelObjectWithChildren, StaplerProxy {
+
+ private static final Logger LOGGER = Logger.getLogger(LogRecorderManager.class.getName());
+
/**
* {@link LogRecorder}s keyed by their {@linkplain LogRecorder#getName()} name}.
*
@@ -104,7 +107,14 @@ public class LogRecorderManager extends AbstractModelObject implements ModelObje
this.recorders = recorders;
Map<String, LogRecorder> values = recorders.stream()
- .collect(toMap(LogRecorder::getName, Function.identity()));
+ .collect(toMap(
+ LogRecorder::getName,
+ Function.identity(),
+ // see JENKINS-68752, ignore duplicates
+ (recorder1, recorder2) -> {
+ LOGGER.warning(String.format("Ignoring duplicate log recorder '%s', check $JENKINS_HOME/log and remove the duplicate recorder", recorder2.getName()));
+ return recorder1;
+ }));
((CopyOnWriteMap<String, LogRecorder>) logRecorders).replaceBy(values);
}
