Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard converters throws NPE when calling canConvert() with 'null' type #116

Closed
dariusz-michura opened this issue May 22, 2018 · 1 comment

Comments

@dariusz-michura
Copy link

commented May 22, 2018

I had to implement my own ConverterLookup which iterates over standard set of converters plus some dedicated ones. I noticed that some of standard converters throws NPE when calling canConvert() with 'null' type. IMHO they should just return 'false' in that case.

Problematic converters:

  • com.thoughtworks.xstream.converters.SingleValueConverterWrapper
  • com.thoughtworks.xstream.converters.basic.CharConverter
  • com.thoughtworks.xstream.converters.collections.BitSetConverter
  • com.thoughtworks.xstream.converters.collections.ArrayConverter
  • com.thoughtworks.xstream.converters.collections.CharArrayConverter
  • com.thoughtworks.xstream.converters.collections.CollectionConverter
  • com.thoughtworks.xstream.converters.collections.MapConverter
  • com.thoughtworks.xstream.converters.collections.TreeMapConverter
  • com.thoughtworks.xstream.converters.collections.TreeSetConverter
  • com.thoughtworks.xstream.converters.extended.EncodedByteArrayConverter
  • com.thoughtworks.xstream.converters.extended.DynamicProxyConverter
  • com.thoughtworks.xstream.converters.extended.JavaMethodConverter
  • com.thoughtworks.xstream.converters.extended.JavaFieldConverter
  • com.thoughtworks.xstream.converters.extended.FontConverter
  • com.thoughtworks.xstream.converters.extended.ColorConverter
  • com.thoughtworks.xstream.converters.extended.LookAndFeelConverter
  • com.thoughtworks.xstream.converters.extended.GregorianCalendarConverter
  • com.thoughtworks.xstream.converters.extended.SubjectConverter
  • com.thoughtworks.xstream.converters.extended.ThrowableConverter
  • com.thoughtworks.xstream.converters.extended.RegexPatternConverter
  • com.thoughtworks.xstream.converters.enums.EnumConverter
  • com.thoughtworks.xstream.converters.enums.EnumSetConverter
@joehni joehni self-assigned this Jun 7, 2018
@joehni joehni added the improvement label Jun 7, 2018
@joehni joehni added this to the 1.4.x milestone Jun 7, 2018
@joehni

This comment has been minimized.

Copy link
Member

commented Jun 7, 2018

Traditionally the converters never checked for null. However, it does not harm and I added these checks now. There have been more converters though.

@joehni joehni closed this in 55c707a Jun 7, 2018
joehni added a commit that referenced this issue Jun 7, 2018
@joehni joehni modified the milestones: 1.4.x, 1.4.11 Oct 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.