From 57996467bc960347705372a9d3d714a76dda729f Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 27 Jan 2026 13:16:35 +0000 Subject: [PATCH 1/4] (chores): reduce cognitive complexity in BeanInfo Extract helper methods from chooseMethod: copyIfNotEmpty, filterMethodLists, selectHandlerAnnotationMethod, hasSingleElement, selectSimpleMethodMatch, selectFromPossibleOperations, selectByParameters. Add null guards to removeAllAbstractMethods, removeNonMatchingMethods, removeAllSetterOrGetterMethods. --- .../apache/camel/component/bean/BeanInfo.java | 236 ++++++++++-------- 1 file changed, 129 insertions(+), 107 deletions(-) diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java index 557934d460627..1aab72b52ede6 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -554,131 +554,144 @@ protected MethodInfo chooseMethod(Object pojo, Exchange exchange, String name) t // and last then try to select the best among the rest // must use defensive copy, to avoid altering the shared lists - // and we want to remove unwanted operations from these local lists - List localOperationsWithBody = null; - if (!operationsWithBody.isEmpty()) { - localOperationsWithBody = new ArrayList<>(operationsWithBody); - } - List localOperationsWithNoBody = null; - if (!operationsWithNoBody.isEmpty()) { - localOperationsWithNoBody = new ArrayList<>(operationsWithNoBody); - } - List localOperationsWithCustomAnnotation = null; - if (!operationsWithCustomAnnotation.isEmpty()) { - localOperationsWithCustomAnnotation = new ArrayList<>(operationsWithCustomAnnotation); - } - List localOperationsWithHandlerAnnotation = null; - if (!operationsWithHandlerAnnotation.isEmpty()) { - localOperationsWithHandlerAnnotation = new ArrayList<>(operationsWithHandlerAnnotation); - } + List localOperationsWithBody = copyIfNotEmpty(operationsWithBody); + List localOperationsWithNoBody = copyIfNotEmpty(operationsWithNoBody); + List localOperationsWithCustomAnnotation = copyIfNotEmpty(operationsWithCustomAnnotation); + List localOperationsWithHandlerAnnotation = copyIfNotEmpty(operationsWithHandlerAnnotation); - // remove all abstract methods - if (localOperationsWithBody != null) { - removeAllAbstractMethods(localOperationsWithBody); - } - if (localOperationsWithNoBody != null) { - removeAllAbstractMethods(localOperationsWithNoBody); + // remove all abstract methods from all lists + removeAllAbstractMethods(localOperationsWithBody); + removeAllAbstractMethods(localOperationsWithNoBody); + removeAllAbstractMethods(localOperationsWithCustomAnnotation); + removeAllAbstractMethods(localOperationsWithHandlerAnnotation); + + // filter or clean methods based on whether a name is specified + filterMethodLists(name, localOperationsWithHandlerAnnotation, localOperationsWithCustomAnnotation, + localOperationsWithBody, localOperationsWithNoBody); + + // check for handler annotation methods + MethodInfo handlerMethod = selectHandlerAnnotationMethod(exchange, localOperationsWithHandlerAnnotation); + if (handlerMethod != null) { + return handlerMethod; } - if (localOperationsWithCustomAnnotation != null) { - removeAllAbstractMethods(localOperationsWithCustomAnnotation); + + // check for single custom annotation method + if (hasSingleElement(localOperationsWithCustomAnnotation)) { + return localOperationsWithCustomAnnotation.get(0); } - if (localOperationsWithHandlerAnnotation != null) { - removeAllAbstractMethods(localOperationsWithHandlerAnnotation); + + // check for simple cases + MethodInfo simpleMatch = selectSimpleMethodMatch(name, localOperationsWithBody, + localOperationsWithNoBody, localOperationsWithCustomAnnotation); + if (simpleMatch != null) { + return simpleMatch; } + // try to find best match from possible operations + return selectFromPossibleOperations(exchange, name, localOperationsWithBody, localOperationsWithCustomAnnotation); + } + + private List copyIfNotEmpty(List source) { + return source.isEmpty() ? null : new ArrayList<>(source); + } + + private void filterMethodLists( + String name, + List handlerOps, + List customOps, + List bodyOps, + List noBodyOps) { if (name != null) { - // filter all lists to only include methods with this name - if (localOperationsWithHandlerAnnotation != null) { - removeNonMatchingMethods(localOperationsWithHandlerAnnotation, name); - } - if (localOperationsWithCustomAnnotation != null) { - removeNonMatchingMethods(localOperationsWithCustomAnnotation, name); - } - if (localOperationsWithBody != null) { - removeNonMatchingMethods(localOperationsWithBody, name); - } - if (localOperationsWithNoBody != null) { - removeNonMatchingMethods(localOperationsWithNoBody, name); - } + removeNonMatchingMethods(handlerOps, name); + removeNonMatchingMethods(customOps, name); + removeNonMatchingMethods(bodyOps, name); + removeNonMatchingMethods(noBodyOps, name); } else { - // remove all getter/setter as we do not want to consider these methods - if (localOperationsWithHandlerAnnotation != null) { - removeAllSetterOrGetterMethods(localOperationsWithHandlerAnnotation); - } - if (localOperationsWithCustomAnnotation != null) { - removeAllSetterOrGetterMethods(localOperationsWithCustomAnnotation); - } - if (localOperationsWithBody != null) { - removeAllSetterOrGetterMethods(localOperationsWithBody); - } - if (localOperationsWithNoBody != null) { - removeAllSetterOrGetterMethods(localOperationsWithNoBody); - } + removeAllSetterOrGetterMethods(handlerOps); + removeAllSetterOrGetterMethods(customOps); + removeAllSetterOrGetterMethods(bodyOps); + removeAllSetterOrGetterMethods(noBodyOps); } + } - if (localOperationsWithHandlerAnnotation != null && localOperationsWithHandlerAnnotation.size() > 1) { - // if we have more than 1 @Handler then its ambiguous - throw new AmbiguousMethodCallException(exchange, localOperationsWithHandlerAnnotation); + private MethodInfo selectHandlerAnnotationMethod(Exchange exchange, List handlerOps) + throws AmbiguousMethodCallException { + if (handlerOps == null) { + return null; } - - if (localOperationsWithHandlerAnnotation != null && localOperationsWithHandlerAnnotation.size() == 1) { - // methods with handler should be preferred - return localOperationsWithHandlerAnnotation.get(0); - } else if (localOperationsWithCustomAnnotation != null && localOperationsWithCustomAnnotation.size() == 1) { - // if there is one method with an annotation then use that one - return localOperationsWithCustomAnnotation.get(0); + if (handlerOps.size() > 1) { + throw new AmbiguousMethodCallException(exchange, handlerOps); } + if (handlerOps.size() == 1) { + return handlerOps.get(0); + } + return null; + } + + private boolean hasSingleElement(List list) { + return list != null && list.size() == 1; + } - // named method and with no parameters + private MethodInfo selectSimpleMethodMatch( + String name, + List bodyOps, + List noBodyOps, + List customOps) { boolean noParameters = name != null && name.endsWith("()"); - if (noParameters && localOperationsWithNoBody != null && localOperationsWithNoBody.size() == 1) { - // if there was a method name configured and it has no parameters, then use the method with no body (eg no parameters) - return localOperationsWithNoBody.get(0); - } else if (!noParameters && localOperationsWithBody != null && localOperationsWithBody.size() == 1 - && localOperationsWithCustomAnnotation == null) { - // if there is one method with body then use that one - return localOperationsWithBody.get(0); - } - - if (localOperationsWithBody != null || localOperationsWithCustomAnnotation != null) { - Collection possibleOperations = new ArrayList<>(); - if (localOperationsWithBody != null) { - possibleOperations.addAll(localOperationsWithBody); - } - if (localOperationsWithCustomAnnotation != null) { - possibleOperations.addAll(localOperationsWithCustomAnnotation); - } + if (noParameters && hasSingleElement(noBodyOps)) { + return noBodyOps.get(0); + } + if (!noParameters && hasSingleElement(bodyOps) && customOps == null) { + return bodyOps.get(0); + } + return null; + } - if (!possibleOperations.isEmpty()) { - MethodInfo answer = null; + private MethodInfo selectFromPossibleOperations( + Exchange exchange, String name, + List bodyOps, + List customOps) + throws AmbiguousMethodCallException { + if (bodyOps == null && customOps == null) { + return null; + } - if (name != null) { - // do we have hardcoded parameters values provided from the method name then use that for matching - String parameters = StringHelper.between(name, "(", ")"); - if (parameters != null) { - // special as we have hardcoded parameters, so we need to choose method that matches those parameters the best - LOG.trace("Choosing best matching method matching parameters: {}", parameters); - answer = chooseMethodWithMatchingParameters(exchange, parameters, possibleOperations); - } - } - if (answer == null) { - // multiple possible operations so find the best suited if possible - answer = chooseMethodWithMatchingBody(exchange, possibleOperations, localOperationsWithCustomAnnotation); - } - if (answer == null && possibleOperations.size() > 1) { - answer = getSingleCovariantMethod(possibleOperations); - } + Collection possibleOperations = new ArrayList<>(); + if (bodyOps != null) { + possibleOperations.addAll(bodyOps); + } + if (customOps != null) { + possibleOperations.addAll(customOps); + } - if (answer == null) { - throw new AmbiguousMethodCallException(exchange, possibleOperations); - } else { - return answer; - } - } + if (possibleOperations.isEmpty()) { + return null; } - // not possible to determine - return null; + MethodInfo answer = selectByParameters(exchange, name, possibleOperations); + if (answer == null) { + answer = chooseMethodWithMatchingBody(exchange, possibleOperations, customOps); + } + if (answer == null && possibleOperations.size() > 1) { + answer = getSingleCovariantMethod(possibleOperations); + } + if (answer == null) { + throw new AmbiguousMethodCallException(exchange, possibleOperations); + } + return answer; + } + + private MethodInfo selectByParameters(Exchange exchange, String name, Collection operations) + throws AmbiguousMethodCallException { + if (name == null) { + return null; + } + String parameters = StringHelper.between(name, "(", ")"); + if (parameters == null) { + return null; + } + LOG.trace("Choosing best matching method matching parameters: {}", parameters); + return chooseMethodWithMatchingParameters(exchange, parameters, operations); } private MethodInfo chooseMethodWithMatchingParameters( @@ -1084,6 +1097,9 @@ private Expression createParameterUnmarshalExpressionForAnnotation( } private static void removeAllSetterOrGetterMethods(List methods) { + if (methods == null) { + return; + } Iterator it = methods.iterator(); while (it.hasNext()) { MethodInfo info = it.next(); @@ -1098,11 +1114,17 @@ private static void removeAllSetterOrGetterMethods(List methods) { } private void removeNonMatchingMethods(List methods, String name) { + if (methods == null) { + return; + } // method does not match so remove it methods.removeIf(info -> !matchMethod(info.getMethod(), name)); } private void removeAllAbstractMethods(List methods) { + if (methods == null) { + return; + } Iterator it = methods.iterator(); while (it.hasNext()) { MethodInfo info = it.next(); From c4a15977a7b668b8b7ccb42a2bdd15cc101de236 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 27 Jan 2026 13:18:10 +0000 Subject: [PATCH 2/4] (chores): reduce cognitive complexity in MethodInfo Extract helper methods from evaluateParameterValue: clipClassSuffix, isParameterTypeNotValue, evaluateSimpleExpression, isValidParameterValue, convertParameterValue. Use guard clauses for early return. --- .../camel/component/bean/MethodInfo.java | 174 +++++++++--------- 1 file changed, 89 insertions(+), 85 deletions(-) diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java index 6254cfecf2082..29c7a46b8e3ee 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/MethodInfo.java @@ -692,99 +692,103 @@ private Object evaluateVarargsParameterExpressions(Exchange exchange, Object bod private Object evaluateParameterValue( Exchange exchange, int index, Object parameterValue, Class parameterType, boolean varargs) { - Object answer = null; - - // convert the parameter value to a String String exp = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, parameterValue); - boolean valid; - if (exp != null) { - int pos1 = exp.indexOf(' '); - int pos2 = exp.indexOf(".class"); - if (pos1 != -1 && pos2 != -1 && pos1 > pos2) { - exp = exp.substring(pos2 + 7); // clip .class - } + if (exp == null) { + return null; + } - // check if its a valid parameter value (no type declared via .class syntax) - valid = BeanHelper.isValidParameterValue(exp); - if (!valid && !varargs) { - // it may be a parameter type instead, and if so, then we should return null, - // as this method is only for evaluating parameter values - Boolean isClass = BeanHelper.isAssignableToExpectedType(exchange.getContext().getClassResolver(), exp, - parameterType); - // the method will return a non-null value if exp is a class - if (isClass != null) { - return null; - } - } + exp = clipClassSuffix(exp); - // use simple language to evaluate the expression, as it may use the simple language to refer to message body, headers etc. - Expression expression = null; - try { - expression = exchange.getContext().resolveLanguage("simple").createExpression(exp); - parameterValue = expression.evaluate(exchange, Object.class); - // use "null" to indicate the expression returned a null value which is a valid response we need to honor - if (parameterValue == null) { - parameterValue = "null"; - } - } catch (Exception e) { - throw new ExpressionEvaluationException( - expression, "Cannot create/evaluate simple expression: " + exp - + " to be bound to parameter at index: " + index + " on method: " + getMethod(), - exchange, e); - } + if (isParameterTypeNotValue(exchange, exp, parameterType, varargs)) { + return null; + } - // special for explicit null parameter values (as end users can explicit indicate they want null as parameter) - // see method javadoc for details - if ("null".equals(parameterValue)) { - return Void.TYPE; - } + parameterValue = evaluateSimpleExpression(exchange, index, exp); - // the parameter value may match the expected type, then we use it as-is - if (varargs || parameterType.isAssignableFrom(parameterValue.getClass())) { - valid = true; - } else { - // String values from the simple language is always valid - if (!valid) { - valid = parameterValue instanceof String; - if (!valid) { - // the parameter value was not already valid, but since the simple language have evaluated the expression - // which may change the parameterValue, so we have to check it again to see if it is now valid - exp = exchange.getContext().getTypeConverter().tryConvertTo(String.class, parameterValue); - // re-validate if the parameter was not valid the first time - valid = BeanHelper.isValidParameterValue(exp); - } - } - } + if ("null".equals(parameterValue)) { + return Void.TYPE; + } - if (valid) { - // we need to unquote String parameters, as the enclosing quotes is there to denote a parameter value - if (parameterValue instanceof String string) { - parameterValue = StringHelper.removeLeadingAndEndingQuotes(string); - } - if (varargs) { - // use the value as-is - answer = parameterValue; - } else { - try { - // it is a valid parameter value, so convert it to the expected type of the parameter - answer = exchange.getContext().getTypeConverter().mandatoryConvertTo(parameterType, exchange, - parameterValue); - if (LOG.isTraceEnabled()) { - LOG.trace("Parameter #{} evaluated as: {} type: {}", index, answer, - org.apache.camel.util.ObjectHelper.type(answer)); - } - } catch (Exception e) { - if (LOG.isDebugEnabled()) { - LOG.debug("Cannot convert from type: {} to type: {} for parameter #{}", - org.apache.camel.util.ObjectHelper.type(parameterValue), parameterType, index); - } - throw new ParameterBindingException(e, method, index, parameterType, parameterValue); - } - } - } + boolean valid = isValidParameterValue(exchange, exp, parameterValue, parameterType, varargs); + if (!valid) { + return null; } - return answer; + return convertParameterValue(exchange, index, parameterValue, parameterType, varargs); + } + + private String clipClassSuffix(String exp) { + int pos1 = exp.indexOf(' '); + int pos2 = exp.indexOf(".class"); + if (pos1 != -1 && pos2 != -1 && pos1 > pos2) { + return exp.substring(pos2 + 7); + } + return exp; + } + + private boolean isParameterTypeNotValue(Exchange exchange, String exp, Class parameterType, boolean varargs) { + boolean valid = BeanHelper.isValidParameterValue(exp); + if (!valid && !varargs) { + Boolean isClass = BeanHelper.isAssignableToExpectedType( + exchange.getContext().getClassResolver(), exp, parameterType); + return isClass != null; + } + return false; + } + + private Object evaluateSimpleExpression(Exchange exchange, int index, String exp) { + Expression expression = null; + try { + expression = exchange.getContext().resolveLanguage("simple").createExpression(exp); + Object result = expression.evaluate(exchange, Object.class); + return result != null ? result : "null"; + } catch (Exception e) { + throw new ExpressionEvaluationException( + expression, "Cannot create/evaluate simple expression: " + exp + + " to be bound to parameter at index: " + index + " on method: " + getMethod(), + exchange, e); + } + } + + private boolean isValidParameterValue( + Exchange exchange, String exp, Object parameterValue, Class parameterType, boolean varargs) { + if (varargs || parameterType.isAssignableFrom(parameterValue.getClass())) { + return true; + } + boolean valid = BeanHelper.isValidParameterValue(exp); + if (valid) { + return true; + } + if (parameterValue instanceof String) { + return true; + } + String reEvaluated = exchange.getContext().getTypeConverter().tryConvertTo(String.class, parameterValue); + return BeanHelper.isValidParameterValue(reEvaluated); + } + + private Object convertParameterValue( + Exchange exchange, int index, Object parameterValue, Class parameterType, boolean varargs) { + if (parameterValue instanceof String string) { + parameterValue = StringHelper.removeLeadingAndEndingQuotes(string); + } + if (varargs) { + return parameterValue; + } + try { + Object answer = exchange.getContext().getTypeConverter().mandatoryConvertTo( + parameterType, exchange, parameterValue); + if (LOG.isTraceEnabled()) { + LOG.trace("Parameter #{} evaluated as: {} type: {}", index, answer, + org.apache.camel.util.ObjectHelper.type(answer)); + } + return answer; + } catch (Exception e) { + if (LOG.isDebugEnabled()) { + LOG.debug("Cannot convert from type: {} to type: {} for parameter #{}", + org.apache.camel.util.ObjectHelper.type(parameterValue), parameterType, index); + } + throw new ParameterBindingException(e, method, index, parameterType, parameterValue); + } } /** From bcab0113a1c63816527c99d38768698d31529058 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 27 Jan 2026 13:27:35 +0000 Subject: [PATCH 3/4] (chores): reduce cognitive complexity in BeanExpression --- .../camel/language/bean/BeanExpression.java | 102 ++++++++++-------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java index 7ca9ad35c97c4..d1227c9713320 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java +++ b/components/camel-bean/src/main/java/org/apache/camel/language/bean/BeanExpression.java @@ -434,70 +434,28 @@ private Object invokeOgnlMethod(BeanHolder beanHolder, String beanName, String o List methods = OgnlHelper.splitOgnl(ognl); for (String methodName : methods) { - BeanHolder holder; - if (beanToCall != null) { - holder = new ConstantBeanHolder(beanToCall, exchange.getContext(), parameterMappingStrategy, beanComponent); - } else if (beanType != null) { - holder = new ConstantTypeBeanHolder(beanType, exchange.getContext(), parameterMappingStrategy, beanComponent); - } else { - holder = null; - } - - // support the null safe operator + BeanHolder holder = createBeanHolder(beanToCall, beanType, exchange); boolean nullSafe = OgnlHelper.isNullSafeOperator(methodName); - if (holder == null) { - String name = getBeanName(exchange, null, beanHolder); - throw new RuntimeBeanExpressionException( - exchange, name, ognl, "last method returned null and therefore cannot continue to invoke method " - + methodName + " on a null instance"); - } + validateHolder(holder, exchange, beanHolder, ognl, methodName); - // keep up with how far are we doing ognlPath += methodName; - - // get rid of leading ?. or . as we only needed that to determine if null safe was enabled or not methodName = OgnlHelper.removeLeadingOperators(methodName); - // are we doing an index lookup (eg in Map/List/array etc)? - String key = null; KeyValueHolder index = OgnlHelper.isOgnlIndex(methodName); + String key = null; if (index != null) { methodName = index.getKey(); key = index.getValue(); } - // only invoke if we have a method name to use to invoke - if (methodName != null) { - Object newResult = invokeBean(holder, beanName, methodName, resultExchange); + result = invokeMethodIfPresent(holder, beanName, methodName, exchange, resultExchange, result); + result = lookupByKeyIfPresent(key, result, resultExchange, exchange, nullSafe, ognlPath, holder); - // check for exception and rethrow if we failed - if (resultExchange.getException() != null) { - throw new RuntimeBeanExpressionException(exchange, beanName, methodName, resultExchange.getException()); - } - - result = newResult; - } - - // if there was a key then we need to lookup using the key - if (key != null) { - // if key is a nested simple expression then re-evaluate that again - if (LanguageSupport.hasSimpleFunction(key)) { - Expression exp = simple.createExpression(key); - exp.init(exchange.getContext()); - key = exp.evaluate(exchange, String.class); - } - if (key != null) { - result = lookupResult(resultExchange, key, result, nullSafe, ognlPath, holder.getBean(exchange)); - } - } - - // check null safe for null results if (result == null && nullSafe) { return null; } - // prepare for next bean to invoke beanToCall = result; beanType = null; } @@ -505,6 +463,56 @@ private Object invokeOgnlMethod(BeanHolder beanHolder, String beanName, String o return result; } + private BeanHolder createBeanHolder(Object beanToCall, Class beanType, Exchange exchange) { + if (beanToCall != null) { + return new ConstantBeanHolder(beanToCall, exchange.getContext(), parameterMappingStrategy, beanComponent); + } + if (beanType != null) { + return new ConstantTypeBeanHolder(beanType, exchange.getContext(), parameterMappingStrategy, beanComponent); + } + return null; + } + + private void validateHolder( + BeanHolder holder, Exchange exchange, BeanHolder originalHolder, String ognl, String methodName) { + if (holder == null) { + String name = getBeanName(exchange, null, originalHolder); + throw new RuntimeBeanExpressionException( + exchange, name, ognl, "last method returned null and therefore cannot continue to invoke method " + + methodName + " on a null instance"); + } + } + + private Object invokeMethodIfPresent( + BeanHolder holder, String beanName, String methodName, + Exchange exchange, Exchange resultExchange, Object currentResult) { + if (methodName == null) { + return currentResult; + } + Object newResult = invokeBean(holder, beanName, methodName, resultExchange); + if (resultExchange.getException() != null) { + throw new RuntimeBeanExpressionException(exchange, beanName, methodName, resultExchange.getException()); + } + return newResult; + } + + private Object lookupByKeyIfPresent( + String key, Object result, Exchange resultExchange, Exchange exchange, + boolean nullSafe, String ognlPath, BeanHolder holder) { + if (key == null) { + return result; + } + if (LanguageSupport.hasSimpleFunction(key)) { + Expression exp = simple.createExpression(key); + exp.init(exchange.getContext()); + key = exp.evaluate(exchange, String.class); + } + if (key != null) { + return lookupResult(resultExchange, key, result, nullSafe, ognlPath, holder.getBean(exchange)); + } + return result; + } + private static Object lookupResult( Exchange exchange, String key, Object result, boolean nullSafe, String ognlPath, Object bean) { StringHelper.notEmpty(key, "key", "in Simple language ognl path: " + ognlPath); From 3827c86c2415b46faf107731e4f907e73f1d9086 Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Tue, 27 Jan 2026 14:44:29 +0000 Subject: [PATCH 4/4] (chores): address PR comment - simplify null check in removeNonMatchingMethods --- .../main/java/org/apache/camel/component/bean/BeanInfo.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java index 1aab72b52ede6..f51695b2796a1 100644 --- a/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/components/camel-bean/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -1114,11 +1114,9 @@ private static void removeAllSetterOrGetterMethods(List methods) { } private void removeNonMatchingMethods(List methods, String name) { - if (methods == null) { - return; + if (methods != null) { + methods.removeIf(info -> !matchMethod(info.getMethod(), name)); } - // method does not match so remove it - methods.removeIf(info -> !matchMethod(info.getMethod(), name)); } private void removeAllAbstractMethods(List methods) {