diff --git a/core/src/main/java/hudson/console/ConsoleLogFilter.java b/core/src/main/java/hudson/console/ConsoleLogFilter.java index c980c1e1fbfceba7d557bf921820c7a7c5c5a775..09359fdedd4942ccd61eb4ac3f6f850c4c5c54b2 100644 --- a/core/src/main/java/hudson/console/ConsoleLogFilter.java +++ b/core/src/main/java/hudson/console/ConsoleLogFilter.java @@ -26,7 +26,14 @@ package hudson.console; import hudson.ExtensionList; import hudson.ExtensionPoint; +import hudson.FilePath; +import hudson.Util; import hudson.model.AbstractBuild; +import hudson.model.Build; +import hudson.model.Job; +import hudson.model.Node; +import hudson.model.Run; +import hudson.scm.SCM; import hudson.tasks.BuildWrapper; import hudson.util.ArgumentListBuilder; import jenkins.model.Jenkins; @@ -48,8 +55,41 @@ public abstract class ConsoleLogFilter implements ExtensionPoint { /** * Called on the start of each build, giving extensions a chance to intercept * the data that is written to the log. + * + * @deprecated as of 1.630. Use {@link #decorateLogger(Run, OutputStream)} */ - public abstract OutputStream decorateLogger(AbstractBuild build, OutputStream logger) throws IOException, InterruptedException; + public OutputStream decorateLogger(AbstractBuild build, OutputStream logger) throws IOException, InterruptedException { + if (Util.isOverridden(ConsoleLogFilter.class, getClass(), "decorateLogger", Run.class, OutputStream.class)) { + // old client calling newer implementation. forward the call. + return decorateLogger((Run) build, logger); + } else { + // happens only if the subtype fails to override neither decorateLogger method + throw new AssertionError("The plugin '" + this.getClass().getName() + "' still uses " + + "deprecated decorateLogger(AbstractBuild,OutputStream) method. " + + "Update the plugin to use setUp(Run,OutputStream) instead."); + } + } + + /** + * Called on the start of each build, giving extensions a chance to intercept + * the data that is written to the log. + * + *
+ * Even though this method is not marked 'abstract', this is the method that must be overridden
+ * by extensions.
+ */
+ public OutputStream decorateLogger(Run build, OutputStream logger) throws IOException, InterruptedException {
+ // this implementation is backward compatibility thunk in case subtypes only override the
+ // old signature (AbstractBuild,OutputStream)
+
+ if (build instanceof AbstractBuild) {
+ // maybe the plugin implements the old signature.
+ return decorateLogger((AbstractBuild) build, logger);
+ } else {
+ // this ConsoleLogFilter can only decorate AbstractBuild, so just pass through
+ return logger;
+ }
+ }
/**
* All the registered {@link ConsoleLogFilter}s.
diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java
index d3f0c11d1c2f84903b2892d6280cf253eef9e191..92b01aa8bed5fe5f10354928d1c2ac8b2a70c203 100644
--- a/core/src/main/java/hudson/model/Run.java
+++ b/core/src/main/java/hudson/model/Run.java
@@ -1710,7 +1710,7 @@ public abstract class Run