Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4311

Custom Converters Do Not Support Generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.0, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5
    • 2.3-next-M1, 2.3.7
    • JSR-372
    • None

    Description

      Hello,

       

      A user posted an issue with the Converter's here:

      https://stackoverflow.com/questions/58825333/facesconverter-is-null-jsf-2-3-cdi-2-0

       

      I investigated the issue, and it is caused by the beanManger#getBeans inside the /org/apache/myfaces/cdi/util/CDIUtils.java file.  The getBeans returns an empty set instead of the converter bean. It searches by class, but it should also check by type.   Since it's an problem with MyFaces code, I thought I'd open an issue here. 

       

      I've provided a patch (overloading the CDIUtil.java methods to accept a type) and sample app (borrowed from StackOverflow). 

       

      I only modified the code to search by type (1) when using getBeans. Type is obtained from creating a TypeLiteral (2).

       

      Since Validators don't check by type as Converters, I can make another fix if you don't have any issues with this patch.

      Please let me know if you have questions or suggestions for the code.

       

      1) https://javaee.github.io/javaee-spec/javadocs/javax/enterprise/inject/spi/BeanManager.html#getBeans-java.lang.reflect.Type-java.lang.annotation.Annotation...-

      2) https://javaee.github.io/javaee-spec/javadocs/javax/enterprise/util/TypeLiteral.html

      Attachments

        1. ConverterTestApp.war
          6 kB
          Volodymyr Siedlecki
        2. MYFACES-4311.patch
          5 kB
          Volodymyr Siedlecki
        3. myfaces-4311-test-case.patch
          8 kB
          Volodymyr Siedlecki
        4. updated_MYFACES-4311.patch
          7 kB
          Volodymyr Siedlecki

        Issue Links

          Activity

            People

              Unassigned Unassigned
              volosied Volodymyr Siedlecki
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m