This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new d2884ea9cc Refactor to avoid use of Hashtable. No functional change.
d2884ea9cc is described below

commit d2884ea9ccf7d8780515344cc7f1b172645b6c03
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 15 17:19:07 2022 +0100

    Refactor to avoid use of Hashtable. No functional change.
---
 .../MbeansDescriptorsIntrospectionSource.java      | 43 ++++++++++------------
 1 file changed, 20 insertions(+), 23 deletions(-)

diff --git 
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
 
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
index 1cb096c9be..05f393d023 100644
--- 
a/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
+++ 
b/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
@@ -21,9 +21,9 @@ import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 
 import javax.management.ObjectName;
@@ -94,7 +94,7 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
 
     // ------------ Implementation for non-declared introspection classes
 
-    private static final Hashtable<String,String> specialMethods = new 
Hashtable<>();
+    private static final Map<String,String> specialMethods = new HashMap<>();
     static {
         specialMethods.put( "preDeregister", "");
         specialMethods.put( "postDeregister", "");
@@ -194,9 +194,9 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
      * @param setAttMap The settable attributes map
      * @param invokeAttMap The invokable attributes map
      */
-    private void initMethods(Class<?> realClass, Method methods[], 
Hashtable<String,Method> attMap,
-            Hashtable<String,Method> getAttMap, Hashtable<String,Method> 
setAttMap,
-            Hashtable<String,Method> invokeAttMap) {
+    private void initMethods(Class<?> realClass, Method methods[], 
Map<String,Method> attMap,
+            Map<String,Method> getAttMap, Map<String,Method> setAttMap,
+            Map<String,Method> invokeAttMap) {
 
         for (Method method : methods) {
             String name = method.getName();
@@ -294,32 +294,29 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
 
         Method methods[]=null;
 
-        Hashtable<String,Method> attMap = new Hashtable<>();
+        Map<String,Method> attMap = new HashMap<>();
         // key: attribute val: getter method
-        Hashtable<String,Method> getAttMap = new Hashtable<>();
+        Map<String,Method> getAttMap = new HashMap<>();
         // key: attribute val: setter method
-        Hashtable<String,Method> setAttMap = new Hashtable<>();
+        Map<String,Method> setAttMap = new HashMap<>();
         // key: operation val: invoke method
-        Hashtable<String,Method> invokeAttMap = new Hashtable<>();
+        Map<String,Method> invokeAttMap = new HashMap<>();
 
         methods = realClass.getMethods();
 
         initMethods(realClass, methods, attMap, getAttMap, setAttMap, 
invokeAttMap );
 
         try {
-
-            Enumeration<String> en = attMap.keys();
-            while( en.hasMoreElements() ) {
-                String name = en.nextElement();
-                AttributeInfo ai=new AttributeInfo();
-                ai.setName( name );
-                Method gm = getAttMap.get(name);
-                if( gm!=null ) {
-                    //ai.setGetMethodObj( gm );
-                    ai.setGetMethod( gm.getName());
-                    Class<?> t=gm.getReturnType();
-                    if( t!=null ) {
-                        ai.setType( t.getName() );
+            for (Entry<String,Method> attEntry : attMap.entrySet()) {
+                String name = attEntry.getKey();
+                AttributeInfo ai = new AttributeInfo();
+                ai.setName(name);
+                Method gm = attEntry.getValue();
+                if (gm != null) {
+                    ai.setGetMethod(gm.getName());
+                    Class<?> t = gm.getReturnType();
+                    if (t != null) {
+                        ai.setType(t.getName());
                     }
                 }
                 Method sm = setAttMap.get(name);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to