davsclaus opened a new pull request, #26863:
URL: https://github.com/apache/camel/pull/26863

   _Claude Code on behalf of Claus Ibsen (davsclaus)_
   
   JIRA: https://issues.apache.org/jira/browse/CAMEL-25009
   
   A review of bean binding and dependency injection 
(`CamelPostProcessorHelper`, `PropertyBindingSupport`) found the bugs below. 
Each fix has a test that fails without it.
   
   1. **`@PropertyInject` used the default value when the property value was 
invalid.** When the property existed but its value could not be converted to 
the type of the field or parameter, such as `port=80a` for an `int`, the 
`defaultValue` was silently used instead, so the configuration mistake went 
unnoticed. The whole method was in one `try`, and any exception, including a 
conversion error, fell back to the default. Now the default is only used when 
the property cannot be resolved, for example because it does not exist. A value 
that cannot be converted fails.
   2. **A constructor or factory method overloaded for the given parameters was 
not found.** When more than one constructor or factory method matched the 
parameters, none was chosen and the bean could not be created. Examples: 
`#class:java.math.BigDecimal(5)` (constructors with `int`, `long` and 
`BigInteger`), a factory method overloaded with `int` and `long`, or one 
overloaded with a bean's own type and a supertype. The most specific one is now 
chosen, the way Java does it: a whole number is an `int` (then a `long`), a 
boolean is a `boolean`, and a bean is its own type rather than a supertype. 
When there is still no single most specific candidate, the previous behaviour 
applies: the fallback candidate with an `Object` parameter, or none.
   3. **Upgrade guide** (4.23) entry for item 1.
   
   No outside PRs overlap with this area.
   
   ### Not changed (left for follow-up)
   - **Numbers other than whole positive ones:** negative numbers such as `-5` 
and decimals such as `1.5` are not recognised as numbers in constructor and 
factory parameters. They are of unknown type, so they don't narrow down the 
candidates. With a single matching constructor they work as before.
   
   ### Tests
   - New 
`CamelPostProcessorHelperTest.testPropertyFieldInvalidValueNotDefaultValue` and 
`PropertyBindingSupportOverloadTest` (a constructor with number overloads, a 
factory method with `int` and `long`, and a constructor with bean-type 
overloads). All fail without the fixes.
   - The full `core/camel-core` suite passes (7593 tests, 0 failures, 44 
skipped), and so does `core/camel-main` (251 tests), which uses 
`PropertyBindingSupport` for all of its configuration.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to