Uploaded image for project: 'Johnzon'
  1. Johnzon
  2. JOHNZON-112

MapperException is thrown when deserializing a customized Enum type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.0
    • 1.1.0
    • Mapper
    • None

    Description

      Given:

      • Customized Enum type that has an alternate naming scheme than typical java Enum.name()
      • Custom Adapter between custom Enum type and String to use in serialization/deserialization

      Expectation:
      Mapper configured to use adapter uses adapter for both serialization and deserialization operations.

      Actual:
      Mapper uses configured adapter for serialization, but uses Enum.valueOf for deserialization, throwing Exceptions on its use.

      Root Cause Analysis:
      It seems that in MappingParserImpl.convertTo(final Type aClass, final String text)
      The custom adapter is attained successfully, but is ignored because "valueOf" method exists with public static modifiers.

      Seems like if the adapter exists, it should be used, only using valueOf as a fallback when it does not...

      Attaching minimal maven project that reproduces problem with "mvn test"

      Attachments

        Activity

          People

            romain.manni-bucau Romain Manni-Bucau
            steven.walters Steven Walters
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: