Package hudson.util

Class RobustCollectionConverter

java.lang.Object
com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter
com.thoughtworks.xstream.converters.collections.CollectionConverter
hudson.util.RobustCollectionConverter
All Implemented Interfaces:
com.thoughtworks.xstream.converters.Converter, com.thoughtworks.xstream.converters.ConverterMatcher
Direct Known Subclasses:
NodeList.ConverterImpl

public class RobustCollectionConverter extends com.thoughtworks.xstream.converters.collections.CollectionConverter
CollectionConverter that ignores XStreamException.

This allows Hudson to load XML files that contain non-existent classes (the expected scenario is that those classes belong to plugins that were unloaded.)

Author:
Kohsuke Kawaguchi
  • Constructor Summary

    Constructors
    Constructor
    Description
    RobustCollectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
     
    RobustCollectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider, Type collectionType)
    Creates a converter that will validate the types of collection elements during deserialization.
    RobustCollectionConverter(com.thoughtworks.xstream.XStream xs)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    protected void
    populateCollection(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context, Collection collection)
     
    unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
     

    Methods inherited from class com.thoughtworks.xstream.converters.collections.CollectionConverter

    addCurrentElementToCollection, createCollection, marshal, populateCollection

    Methods inherited from class com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter

    mapper, readBareItem, readCompleteItem, readItem, writeBareItem, writeCompleteItem, writeItem, writeNullItem

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RobustCollectionConverter

      public RobustCollectionConverter(com.thoughtworks.xstream.XStream xs)
    • RobustCollectionConverter

      public RobustCollectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider)
    • RobustCollectionConverter

      public RobustCollectionConverter(com.thoughtworks.xstream.mapper.Mapper mapper, com.thoughtworks.xstream.converters.reflection.ReflectionProvider reflectionProvider, Type collectionType)
      Creates a converter that will validate the types of collection elements during deserialization.

      Elements with invalid types will be omitted from deserialized collections and may result in an OldDataMonitor warning.

      This type checking currently uses the erasure of the type argument, so for example, the element type for a List<Optional<Integer>> is just a raw Optional, so non-integer values inside of the optional would still deserialize successfully and the resulting optional would be included in the list.

      See Also:
  • Method Details

    • canConvert

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

      public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context)
      Specified by:
      unmarshal in interface com.thoughtworks.xstream.converters.Converter
      Overrides:
      unmarshal in class com.thoughtworks.xstream.converters.collections.CollectionConverter
    • populateCollection

      protected void populateCollection(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, com.thoughtworks.xstream.converters.UnmarshallingContext context, Collection collection)
      Overrides:
      populateCollection in class com.thoughtworks.xstream.converters.collections.CollectionConverter