Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-20700

camel-core: ReflectionHelper.setField may fail for numeric type fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.3.0, 4.4.0, 4.5.0
    • 4.4.3, 4.6.0
    • camel-core
    • None
    • Unknown

    Description

      Originally reported here:

      https://camel.zulipchat.com/#narrow/stream/257302-camel-quarkus/topic/PropertyInject.20failure.20in.20CxfConfigurer

      If you use @PropertyInject like:

      public class Foo {
          @PropertyInject(value = "1")
          private Integer bar;
      }
      

      Then you get an exception like:

      java.lang.UnsupportedOperationException: Cannot inject value of class: class java.lang.Integer into: private java.lang.Integer
      

      The original exception is swallowed, but it's something like:

      IllegalArgumentException: Can not set java.lang.Integer field to int(1)
      

      You can't use Field.setInt etc where the field type is not a primitive. You have to use Field.set in that case.

      https://docs.oracle.com/javase/tutorial/reflect/member/fieldTrouble.html

      Maybe it's related to this change:

      https://github.com/apache/camel/commit/df19aec009164ba821c60518651dfc5eda3aee7d

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            jamesnetherton James Netherton
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: