Class AppendTextBadgeSummaryActionConverter

java.lang.Object
hudson.util.RobustReflectionConverter
org.jvnet.hudson.plugins.groovypostbuild.AppendTextBadgeSummaryActionConverter
All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher

public class AppendTextBadgeSummaryActionConverter extends RobustReflectionConverter
Makes AppendTextBadgeSummaryAction persist as a plain BadgeSummaryAction in build.xml, without touching Java's own serialization contract.

A writeReplace() method would do the same substitution, but it is honored by any Java serialization, not just Run.XSTREAM2: Pipeline's CPS interpreter persists a running program's local variables (including whatever a script assigned manager.createSummary(...) to) with plain ObjectOutputStream/ ObjectInputStream across every durability checkpoint. A writeReplace()-based shim would come back from that round trip as a plain BadgeSummaryAction too, so a script that called appendText(...) again after the controller resumed would fail with MissingMethodException - breaking in Pipeline the exact thing being fixed in freestyle.

Registering this as an XStream Converter instead keeps the substitution confined to Run.XSTREAM2: only marshal(java.lang.Object, com.thoughtworks.xstream.io.HierarchicalStreamWriter, com.thoughtworks.xstream.converters.MarshallingContext) is overridden, to write a plain BadgeSummaryAction's fields (with the same resolves-to attribute writeReplace() would have produced) in place of this class's own; RobustReflectionConverter.unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader, com.thoughtworks.xstream.converters.UnmarshallingContext) is inherited unchanged from RobustReflectionConverter, so reading is unaffected either way. ObjectOutputStream never consults registered XStream converters, so CPS state keeps the real shim, with appendText intact, across every checkpoint.

  • Constructor Details

    • AppendTextBadgeSummaryActionConverter

      public AppendTextBadgeSummaryActionConverter(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
  • Method Details

    • canConvert

      public boolean canConvert(Class type)
      Specified by:
      canConvert in interface com.thoughtworks.xstream.converters.ConverterMatcher
      Overrides:
      canConvert in class RobustReflectionConverter
    • marshal

      public void marshal(Object original, com.thoughtworks.xstream.io.HierarchicalStreamWriter writer, com.thoughtworks.xstream.converters.MarshallingContext context)
      Specified by:
      marshal in interface com.thoughtworks.xstream.converters.Converter
      Overrides:
      marshal in class RobustReflectionConverter