From c7062bae2e719dfe9444dc67974fa22d0ff4557e Mon Sep 17 00:00:00 2001 From: Kui LIU Date: Wed, 11 Oct 2017 11:15:23 +0200 Subject: [PATCH] Replace the keySet iterator with an entrySet iterator. The current source code accesses the value of a Map entry of methodMap, using a key that is retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the methodMap, to avoid the Map.get(key) lookup. http://findbugs.sourceforge.net/bugDescriptions.html#WMI_WRONG_MAP_ITERATOR --- .../main/java/org/apache/camel/component/bean/BeanInfo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java index 48eb177d4b715..16287933c0304 100644 --- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java +++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java @@ -401,9 +401,10 @@ public MethodInfo getMethodInfo(Method method) { MethodInfo answer = methodMap.get(method); if (answer == null) { // maybe the method overrides, and the method map keeps info of the source override we can use - for (Method source : methodMap.keySet()) { + for (Map.Entry methodEntry : methodMap.entrySet()) { + Method source = methodEntry.getKey(); if (ObjectHelper.isOverridingMethod(getType(), source, method, false)) { - answer = methodMap.get(source); + answer = methodEntry.getValue(); break; } }