From a4aec926848711eb9ed04b48e28c3102b6d4ce44 Mon Sep 17 00:00:00 2001 From: Kui LIU Date: Wed, 11 Oct 2017 14:51:12 +0200 Subject: [PATCH] Fix the inefficient use of keySet iterator with entrySet iterator. The current source code accesses the key and value of a Hashtable entry, using a key that is retrieved from a keySet iterator. It is more efficient to use an iterator on the entrySet of the Hashtable, to avoid the Map.get(key) lookup. http://findbugs.sourceforge.net/bugDescriptions.html#WMI_WRONG_MAP_ITERATOR --- .../ant/taskdefs/optional/ejb/GenericDeploymentTool.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java index 16bde5d80..7324bdcf7 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java @@ -760,11 +760,12 @@ public class GenericDeploymentTool implements EJBDeploymentTool { jarStream.setMethod(JarOutputStream.DEFLATED); // Loop through all the class files found and add them to the jar - for (String entryName : files.keySet()) { + for (Map.Entry entryFiles : files.entrySet()) { + String entryName = entryFiles.getKey(); if (entryName.equals(MANIFEST)) { continue; } - File entryFile = files.get(entryName); + File entryFile = entryFiles.getValue(); log("adding file '" + entryName + "'", Project.MSG_VERBOSE); addFileToJar(jarStream, entryFile, entryName);