gnodet-bot commented on code in PR #28651:
URL: https://github.com/apache/camel/pull/28651#discussion_r4408649750
##########
core/camel-base/src/main/java/org/apache/camel/impl/converter/EnumTypeConverter.java:
##########
@@ -30,6 +30,14 @@
*/
public class EnumTypeConverter extends TypeConverterSupport implements
CamelContextAware {
+ // getEnumConstants returns a new copy of the constants on every call
+ private static final ClassValue<Enum<?>[]> ENUM_CONSTANTS = new
ClassValue<>() {
+ @Override
+ protected Enum<?>[] computeValue(Class<?> type) {
+ return (Enum<?>[]) type.getEnumConstants();
+ }
Review Comment:
💡 **Missing `@SuppressWarnings("unchecked")`**: this cast — `(Enum<?>[])
type.getEnumConstants()` — is unchecked. The old `doConvertTo` had
`@SuppressWarnings("unchecked")` for the same pattern; the annotation was
removed but the cast moved here. Safe at runtime (only reached for enum types,
guarded by `isEnum()` at the call site), but emits a compiler warning.
```suggestion
@Override
@SuppressWarnings("unchecked")
protected Enum<?>[] computeValue(Class<?> type) {
return (Enum<?>[]) type.getEnumConstants();
}
```
--
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]