Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-6676

MapToMapConverter cannot handle unbounded wildcard Value type

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0 GA
    • Fix Version/s: 3.0.1
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      We have a UrlBasedViewResolver bean for which we want to inject custom attributes using the attributesMap property. The property is of type Map<String, ?> and trying to inject a map using XML config (<map><entry key="test" value="test" /></map>) will create a LinkedHashMap and trigger the MapToMapConverter, which will try to convert the LinkedHashMap to a map of type Map<String, ?>. This doesn't work as the TypeDescriptor for Map<String, ?> reports that the value doesn't have a type, i.e. TypeDescriptor.NULL, which will eventually lead to a RuntimeException being thrown and as such the application cannot be started. I guess it is the wildcard that makes it difficult for the TypeDescriptor to decide on a type for the value, as the GenericCollectionTypeResolver cannot get a type for the unbounded wildcard.

      I don't know if the problem is supposed to be fixed in UrlBasedViewResolver (by changing the type of the argument to setAttributesMap) or if it is the MapToMapConverter, TypeDescriptor or GenericCollectionTypeResolver that is at fault and should be fixed.

        Issue Links

          Activity

          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          Thanks for reporting this! I've fixed the type assignability check for wildcarded Maps accordingly.

          This will be available in tonight's 3.0.1. snapshot already. Feel free to give it a try...

          Juergen

          Show
          juergen.hoeller Juergen Hoeller added a comment - Thanks for reporting this! I've fixed the type assignability check for wildcarded Maps accordingly. This will be available in tonight's 3.0.1. snapshot already. Feel free to give it a try... Juergen

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              mel Mandus Elfving
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                7 years, 32 weeks, 3 days ago