Re: [tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-16 Thread Mark Thomas

On 15/09/2022 22:37, Christopher Schultz wrote:

Mark,

On 9/15/22 11:26, Mark Thomas wrote:

On 15/09/2022 16:23, ma...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/main by this push:
  new 00cf721f14 Refactor to avoid use of Hashtable. No 
functional change.

00cf721f14 is described below

commit 00cf721f14ac90e7ebc372a5303603ca408fc999
Author: Mark Thomas 
AuthorDate: Thu Sep 15 16:23:49 2022 +0100

 Refactor to avoid use of Hashtable. No functional change.


Any objections to back-porting this?

It changes some protected API for the CGIServlet inner classes (and 
the CGI Servlet is final). That seems pretty low risk to me.


I haven't read through the whole class, but is there any risk of 
multi-threaded access?


I don't believe so.


At what point is "shellEnv" stable?


Servlet initialisation.


Can it be wrapped in Collections.unmodifiableMap() at any point?


It could at the end of init(ServletConfig).


Can that be added to any other instances of Map<> usage in this class?


Yes.

I'm in two minds whether to use Collections.unmodifiableMap(). It makes 
the intended usage clearer (good) but it isn't necessary (bad) since the 
Maps aren't exposed to applications.


Mark

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



Re: [tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread Christopher Schultz

Mark,

On 9/15/22 11:26, Mark Thomas wrote:

On 15/09/2022 16:23, ma...@apache.org wrote:

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

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


The following commit(s) were added to refs/heads/main by this push:
  new 00cf721f14 Refactor to avoid use of Hashtable. No functional 
change.

00cf721f14 is described below

commit 00cf721f14ac90e7ebc372a5303603ca408fc999
Author: Mark Thomas 
AuthorDate: Thu Sep 15 16:23:49 2022 +0100

 Refactor to avoid use of Hashtable. No functional change.


Any objections to back-porting this?

It changes some protected API for the CGIServlet inner classes (and the 
CGI Servlet is final). That seems pretty low risk to me.


I haven't read through the whole class, but is there any risk of 
multi-threaded access?


At what point is "shellEnv" stable? Can it be wrapped in 
Collections.unmodifiableMap() at any point? Can that be added to any 
other instances of Map<> usage in this class?


-chris


---
  java/org/apache/catalina/servlets/CGIServlet.java | 30 
+++

  1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/java/org/apache/catalina/servlets/CGIServlet.java 
b/java/org/apache/catalina/servlets/CGIServlet.java

index 2f26337a41..dbc941dce5 100644
--- a/java/org/apache/catalina/servlets/CGIServlet.java
+++ b/java/org/apache/catalina/servlets/CGIServlet.java
@@ -29,10 +29,11 @@ import java.nio.file.Files;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.Enumeration;
+import java.util.HashMap;
  import java.util.HashSet;
-import java.util.Hashtable;
  import java.util.List;
  import java.util.Locale;
+import java.util.Map;
  import java.util.Map.Entry;
  import java.util.Set;
  import java.util.StringTokenizer;
@@ -306,7 +307,7 @@ public final class CGIServlet extends HttpServlet {
  private static final Object expandFileLock = new Object();
  /** the shell environment variables to be passed to the CGI 
script */

-    private final Hashtable shellEnv = new Hashtable<>();
+    private final Map shellEnv = new HashMap<>();
  /**
   * Enable creation of script command line arguments from 
query-string.

@@ -698,7 +699,7 @@ public final class CGIServlet extends HttpServlet {
  private File tmpDir = null;
  /** derived cgi environment */
-    private Hashtable env = null;
+    private Map env = null;
  /** cgi command to be invoked */
  private String command = null;
@@ -979,7 +980,7 @@ public final class CGIServlet extends HttpServlet {
   */
  // Add the shell environment variables (if any)
-    Hashtable envp = new Hashtable<>(shellEnv);
+    Map envp = new HashMap<>(shellEnv);
  // Add the CGI environment variables
  String sPathInfoOrig = null;
@@ -1317,7 +1318,7 @@ public final class CGIServlet extends HttpServlet {
   * @return   CGI environment
   *
   */
-    protected Hashtable getEnvironment() {
+    protected Map getEnvironment() {
  return env;
  }
@@ -1416,7 +1417,7 @@ public final class CGIServlet extends HttpServlet {
  private final String command;
  /** environment used when invoking the cgi script */
-    private final Hashtable env;
+    private final Map env;
  /** working directory used when invoking the cgi script */
  private final File wd;
@@ -1448,7 +1449,7 @@ public final class CGIServlet extends HttpServlet {
   * @param  params   ArrayList with the script's query 
command line

   *  parameters as strings
   */
-    protected CGIRunner(String command, Hashtable 
env,

+    protected CGIRunner(String command, Map env,
  File wd, ArrayList params) {
  this.command = command;
  this.env = env;
@@ -1511,20 +1512,17 @@ public final class CGIServlet extends 
HttpServlet {

   * key/value pair in the Hashtable to a String in the form
   * "key=value" (hashkey + "=" + hash.get(hashkey).toString())
   *
- * @param  h   Hashtable to convert
+ * @param  map Hashtable to convert
   *
   * @return converted string array
   *
   * @exception  NullPointerException   if a hash key has a 
null value

   *
   */
-    protected String[] hashToStringArray(Hashtable h)
-    throws NullPointerException {
-    List list = new ArrayList<>(h.size());
-    Enumeration e = h.keys();
-    while (e.hasMoreElements()) {
-    String k = e.nextElement();
-    list.add(k + "=" + h.get(k).toString());
+    protected String[] mapToStringArray(Map map) throws 
NullPointerException {

+    List list = new ArrayList<>(map.size());
+ 

[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit da947664cbafa249d33b0d23a3b198a12af11f79
Author: Mark Thomas 
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 specialMethods = new 
Hashtable<>();
+private static final Map 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 attMap,
-Hashtable getAttMap, Hashtable 
setAttMap,
-Hashtable invokeAttMap) {
+private void initMethods(Class realClass, Method methods[], 
Map attMap,
+Map getAttMap, Map setAttMap,
+Map invokeAttMap) {
 
 for (Method method : methods) {
 String name = method.getName();
@@ -294,32 +294,29 @@ public class MbeansDescriptorsIntrospectionSource extends 
ModelerSource
 
 Method methods[]=null;
 
-Hashtable attMap = new Hashtable<>();
+Map attMap = new HashMap<>();
 // key: attribute val: getter method
-Hashtable getAttMap = new Hashtable<>();
+Map getAttMap = new HashMap<>();
 // key: attribute val: setter method
-Hashtable setAttMap = new Hashtable<>();
+Map setAttMap = new HashMap<>();
 // key: operation val: invoke method
-Hashtable invokeAttMap = new Hashtable<>();
+Map invokeAttMap = new HashMap<>();
 
 methods = realClass.getMethods();
 
 initMethods(realClass, methods, attMap, getAttMap, setAttMap, 
invokeAttMap );
 
 try {
-
-Enumeration 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 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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 8278c1c80df394365af5559166bf675edd294555
Author: Mark Thomas 
AuthorDate: Thu Sep 15 17:04:39 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/naming/ContextAccessController.java |  7 ---
 java/org/apache/naming/ContextBindings.java | 13 +++--
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/naming/ContextAccessController.java 
b/java/org/apache/naming/ContextAccessController.java
index 301d648eea..0fad089be5 100644
--- a/java/org/apache/naming/ContextAccessController.java
+++ b/java/org/apache/naming/ContextAccessController.java
@@ -16,7 +16,8 @@
  */
 package org.apache.naming;
 
-import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * Handles the access control on the JNDI contexts.
@@ -30,13 +31,13 @@ public class ContextAccessController {
 /**
  * Catalina context names on which writing is not allowed.
  */
-private static final Hashtable readOnlyContexts = new 
Hashtable<>();
+private static final Map readOnlyContexts = new 
ConcurrentHashMap<>();
 
 
 /**
  * Security tokens repository.
  */
-private static final Hashtable securityTokens = new 
Hashtable<>();
+private static final Map securityTokens = new 
ConcurrentHashMap<>();
 
 
 // - Public Methods
diff --git a/java/org/apache/naming/ContextBindings.java 
b/java/org/apache/naming/ContextBindings.java
index ae509b27b7..baf3ce2bdb 100644
--- a/java/org/apache/naming/ContextBindings.java
+++ b/java/org/apache/naming/ContextBindings.java
@@ -16,7 +16,8 @@
  */
 package org.apache.naming;
 
-import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
@@ -42,31 +43,31 @@ public class ContextBindings {
 /**
  * Bindings object - naming context. Keyed by object.
  */
-private static final Hashtable objectBindings = new 
Hashtable<>();
+private static final Map objectBindings = new 
ConcurrentHashMap<>();
 
 
 /**
  * Bindings thread - naming context. Keyed by thread.
  */
-private static final Hashtable threadBindings = new 
Hashtable<>();
+private static final Map threadBindings = new 
ConcurrentHashMap<>();
 
 
 /**
  * Bindings thread - object. Keyed by thread.
  */
-private static final Hashtable threadObjectBindings = new 
Hashtable<>();
+private static final Map threadObjectBindings = new 
ConcurrentHashMap<>();
 
 
 /**
  * Bindings class loader - naming context. Keyed by class loader.
  */
-private static final Hashtable clBindings = new 
Hashtable<>();
+private static final Map clBindings = new 
ConcurrentHashMap<>();
 
 
 /**
  * Bindings class loader - object. Keyed by class loader.
  */
-private static final Hashtable clObjectBindings = new 
Hashtable<>();
+private static final Map clObjectBindings = new 
ConcurrentHashMap<>();
 
 
 /**


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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 4c213c508d349f30c17ea493797bca405cd63f62
Author: Mark Thomas 
AuthorDate: Thu Sep 15 16:54:30 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/jasper/compiler/Generator.java | 29 +-
 .../apache/jasper/compiler/TagLibraryInfoImpl.java |  4 +--
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/java/org/apache/jasper/compiler/Generator.java 
b/java/org/apache/jasper/compiler/Generator.java
index 4a85866903..34c6e41abf 100644
--- a/java/org/apache/jasper/compiler/Generator.java
+++ b/java/org/apache/jasper/compiler/Generator.java
@@ -29,10 +29,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
@@ -913,9 +911,9 @@ class Generator {
  * handlers: : tag short name : introspection info of tag
  * handler for  tag
  */
-private final Hashtable> 
handlerInfos;
+private final Map> handlerInfos;
 
-private final Hashtable tagVarNumbers;
+private final Map tagVarNumbers;
 
 private String parent;
 
@@ -956,8 +954,8 @@ class Generator {
 this.fragmentHelperClass = fragmentHelperClass;
 this.useInstanceManagerForTags = useInstanceManagerForTags;
 methodNesting = 0;
-handlerInfos = new Hashtable<>();
-tagVarNumbers = new Hashtable<>();
+handlerInfos = new HashMap<>();
+tagVarNumbers = new HashMap<>();
 textMap = new HashMap<>();
 }
 
@@ -1794,7 +1792,7 @@ class Generator {
 
 // Compute attribute value string for XML-style and named
 // attributes
-Hashtable map = new Hashtable<>();
+Map map = new HashMap<>();
 // Validator ensures this is non-null
 Node.JspAttribute[] attrs = n.getJspAttributes();
 for (int i = 0; i < attrs.length; i++) {
@@ -1839,9 +1837,7 @@ class Generator {
 out.print(" + " + elemName);
 
 // Write remaining attributes
-Enumeration enumeration = map.keys();
-while (enumeration.hasMoreElements()) {
-String attrName = enumeration.nextElement();
+for (String attrName : map.keySet()) {
 out.print(map.get(attrName));
 }
 
@@ -2137,10 +2133,9 @@ class Generator {
 
 private TagHandlerInfo getTagHandlerInfo(Node.CustomTag n)
 throws JasperException {
-Hashtable handlerInfosByShortName =
-handlerInfos.get(n.getPrefix());
+Map handlerInfosByShortName = 
handlerInfos.get(n.getPrefix());
 if (handlerInfosByShortName == null) {
-handlerInfosByShortName = new Hashtable<>();
+handlerInfosByShortName = new HashMap<>();
 handlerInfos.put(n.getPrefix(), handlerInfosByShortName);
 }
 TagHandlerInfo handlerInfo =
@@ -3815,9 +3810,9 @@ class Generator {
  */
 private static class TagHandlerInfo {
 
-private Hashtable methodMaps;
+private Map methodMaps;
 
-private Hashtable> propertyEditorMaps;
+private Map> propertyEditorMaps;
 
 private Class tagHandlerClass;
 
@@ -3835,8 +3830,8 @@ class Generator {
 TagHandlerInfo(Node n, Class tagHandlerClass,
 ErrorDispatcher err) throws JasperException {
 this.tagHandlerClass = tagHandlerClass;
-this.methodMaps = new Hashtable<>();
-this.propertyEditorMaps = new Hashtable<>();
+this.methodMaps = new HashMap<>();
+this.propertyEditorMaps = new HashMap<>();
 
 try {
 BeanInfo tagClassInfo = 
Introspector.getBeanInfo(tagHandlerClass);
diff --git a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java 
b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
index bef122c18d..d481e0d454 100644
--- a/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
+++ b/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
@@ -25,8 +25,8 @@ import java.net.URL;
 import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -349,7 +349,7 @@ class TagLibraryInfoImpl extends 

[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit f2110418d1d37972780364b5b29c35f61506b1bf
Author: Mark Thomas 
AuthorDate: Thu Sep 15 16:34:52 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/coyote/ajp/Constants.java | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/ajp/Constants.java 
b/java/org/apache/coyote/ajp/Constants.java
index 17e57a7fd8..1da971b589 100644
--- a/java/org/apache/coyote/ajp/Constants.java
+++ b/java/org/apache/coyote/ajp/Constants.java
@@ -16,7 +16,8 @@
  */
 package org.apache.coyote.ajp;
 
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Constants.
@@ -211,13 +212,13 @@ public final class Constants {
 return responseTransArray[code];
 }
 
-private static final Hashtable  responseTransHash = new 
Hashtable<>(20);
+private static final Map  responseTransMap = new 
HashMap<>(20);
 
 static {
 try {
 int i;
 for (i = 0; i < SC_RESP_AJP13_MAX; i++) {
-responseTransHash.put(getResponseHeaderForCode(i), 
Integer.valueOf(0xA001 + i));
+responseTransMap.put(getResponseHeaderForCode(i), 
Integer.valueOf(0xA001 + i));
 }
 }
 catch (Exception e) {
@@ -226,7 +227,7 @@ public final class Constants {
 }
 
 public static final int getResponseAjpIndex(String header) {
-Integer i = responseTransHash.get(header);
+Integer i = responseTransMap.get(header);
 if (i == null) {
 return 0;
 } else {


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



Re: [tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread Mark Thomas

On 15/09/2022 16:23, ma...@apache.org wrote:

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

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


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

commit 00cf721f14ac90e7ebc372a5303603ca408fc999
Author: Mark Thomas 
AuthorDate: Thu Sep 15 16:23:49 2022 +0100

 Refactor to avoid use of Hashtable. No functional change.


Any objections to back-porting this?

It changes some protected API for the CGIServlet inner classes (and the 
CGI Servlet is final). That seems pretty low risk to me.


Mark


---
  java/org/apache/catalina/servlets/CGIServlet.java | 30 +++
  1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/java/org/apache/catalina/servlets/CGIServlet.java 
b/java/org/apache/catalina/servlets/CGIServlet.java
index 2f26337a41..dbc941dce5 100644
--- a/java/org/apache/catalina/servlets/CGIServlet.java
+++ b/java/org/apache/catalina/servlets/CGIServlet.java
@@ -29,10 +29,11 @@ import java.nio.file.Files;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.Enumeration;
+import java.util.HashMap;
  import java.util.HashSet;
-import java.util.Hashtable;
  import java.util.List;
  import java.util.Locale;
+import java.util.Map;
  import java.util.Map.Entry;
  import java.util.Set;
  import java.util.StringTokenizer;
@@ -306,7 +307,7 @@ public final class CGIServlet extends HttpServlet {
  private static final Object expandFileLock = new Object();
  
  /** the shell environment variables to be passed to the CGI script */

-private final Hashtable shellEnv = new Hashtable<>();
+private final Map shellEnv = new HashMap<>();
  
  /**

   * Enable creation of script command line arguments from query-string.
@@ -698,7 +699,7 @@ public final class CGIServlet extends HttpServlet {
  private File tmpDir = null;
  
  /** derived cgi environment */

-private Hashtable env = null;
+private Map env = null;
  
  /** cgi command to be invoked */

  private String command = null;
@@ -979,7 +980,7 @@ public final class CGIServlet extends HttpServlet {
   */
  
  // Add the shell environment variables (if any)

-Hashtable envp = new Hashtable<>(shellEnv);
+Map envp = new HashMap<>(shellEnv);
  
  // Add the CGI environment variables

  String sPathInfoOrig = null;
@@ -1317,7 +1318,7 @@ public final class CGIServlet extends HttpServlet {
   * @return   CGI environment
   *
   */
-protected Hashtable getEnvironment() {
+protected Map getEnvironment() {
  return env;
  }
  
@@ -1416,7 +1417,7 @@ public final class CGIServlet extends HttpServlet {

  private final String command;
  
  /** environment used when invoking the cgi script */

-private final Hashtable env;
+private final Map env;
  
  /** working directory used when invoking the cgi script */

  private final File wd;
@@ -1448,7 +1449,7 @@ public final class CGIServlet extends HttpServlet {
   * @param  params   ArrayList with the script's query command line
   *  parameters as strings
   */
-protected CGIRunner(String command, Hashtable env,
+protected CGIRunner(String command, Map env,
  File wd, ArrayList params) {
  this.command = command;
  this.env = env;
@@ -1511,20 +1512,17 @@ public final class CGIServlet extends HttpServlet {
   * key/value pair in the Hashtable to a String in the form
   * "key=value" (hashkey + "=" + hash.get(hashkey).toString())
   *
- * @param  h   Hashtable to convert
+ * @param  map Hashtable to convert
   *
   * @return converted string array
   *
   * @exception  NullPointerException   if a hash key has a null value
   *
   */
-protected String[] hashToStringArray(Hashtable h)
-throws NullPointerException {
-List list = new ArrayList<>(h.size());
-Enumeration e = h.keys();
-while (e.hasMoreElements()) {
-String k = e.nextElement();
-list.add(k + "=" + h.get(k).toString());
+protected String[] mapToStringArray(Map map) throws 
NullPointerException {
+List list = new ArrayList<>(map.size());
+for (Entry entry : map.entrySet()) {
+list.add(entry.getKey() + "=" + entry.getValue().toString());
  }
  return list.toArray(new String[0]);
  }
@@ -1630,7 +1628,7 @@ public final class CGIServlet extends HttpServlet {
  rt = 

[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 00cf721f14ac90e7ebc372a5303603ca408fc999
Author: Mark Thomas 
AuthorDate: Thu Sep 15 16:23:49 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/catalina/servlets/CGIServlet.java | 30 +++
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/java/org/apache/catalina/servlets/CGIServlet.java 
b/java/org/apache/catalina/servlets/CGIServlet.java
index 2f26337a41..dbc941dce5 100644
--- a/java/org/apache/catalina/servlets/CGIServlet.java
+++ b/java/org/apache/catalina/servlets/CGIServlet.java
@@ -29,10 +29,11 @@ import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.StringTokenizer;
@@ -306,7 +307,7 @@ public final class CGIServlet extends HttpServlet {
 private static final Object expandFileLock = new Object();
 
 /** the shell environment variables to be passed to the CGI script */
-private final Hashtable shellEnv = new Hashtable<>();
+private final Map shellEnv = new HashMap<>();
 
 /**
  * Enable creation of script command line arguments from query-string.
@@ -698,7 +699,7 @@ public final class CGIServlet extends HttpServlet {
 private File tmpDir = null;
 
 /** derived cgi environment */
-private Hashtable env = null;
+private Map env = null;
 
 /** cgi command to be invoked */
 private String command = null;
@@ -979,7 +980,7 @@ public final class CGIServlet extends HttpServlet {
  */
 
 // Add the shell environment variables (if any)
-Hashtable envp = new Hashtable<>(shellEnv);
+Map envp = new HashMap<>(shellEnv);
 
 // Add the CGI environment variables
 String sPathInfoOrig = null;
@@ -1317,7 +1318,7 @@ public final class CGIServlet extends HttpServlet {
  * @return   CGI environment
  *
  */
-protected Hashtable getEnvironment() {
+protected Map getEnvironment() {
 return env;
 }
 
@@ -1416,7 +1417,7 @@ public final class CGIServlet extends HttpServlet {
 private final String command;
 
 /** environment used when invoking the cgi script */
-private final Hashtable env;
+private final Map env;
 
 /** working directory used when invoking the cgi script */
 private final File wd;
@@ -1448,7 +1449,7 @@ public final class CGIServlet extends HttpServlet {
  * @param  params   ArrayList with the script's query command line
  *  parameters as strings
  */
-protected CGIRunner(String command, Hashtable env,
+protected CGIRunner(String command, Map env,
 File wd, ArrayList params) {
 this.command = command;
 this.env = env;
@@ -1511,20 +1512,17 @@ public final class CGIServlet extends HttpServlet {
  * key/value pair in the Hashtable to a String in the form
  * "key=value" (hashkey + "=" + hash.get(hashkey).toString())
  *
- * @param  h   Hashtable to convert
+ * @param  map Hashtable to convert
  *
  * @return converted string array
  *
  * @exception  NullPointerException   if a hash key has a null value
  *
  */
-protected String[] hashToStringArray(Hashtable h)
-throws NullPointerException {
-List list = new ArrayList<>(h.size());
-Enumeration e = h.keys();
-while (e.hasMoreElements()) {
-String k = e.nextElement();
-list.add(k + "=" + h.get(k).toString());
+protected String[] mapToStringArray(Map map) throws 
NullPointerException {
+List list = new ArrayList<>(map.size());
+for (Entry entry : map.entrySet()) {
+list.add(entry.getKey() + "=" + entry.getValue().toString());
 }
 return list.toArray(new String[0]);
 }
@@ -1630,7 +1628,7 @@ public final class CGIServlet extends HttpServlet {
 rt = Runtime.getRuntime();
 proc = rt.exec(
 cmdAndArgs.toArray(new String[0]),
-hashToStringArray(env), wd);
+mapToStringArray(env), wd);
 
 String sContentLength = env.get("CONTENT_LENGTH");
 



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 336fd8bc14373223e159578b1fb82550ce5816ce
Author: Mark Thomas 
AuthorDate: Thu Sep 15 15:48:18 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/catalina/valves/rewrite/RewriteValve.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/valves/rewrite/RewriteValve.java 
b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
index e1589f801a..2cfac3d878 100644
--- a/java/org/apache/catalina/valves/rewrite/RewriteValve.java
+++ b/java/org/apache/catalina/valves/rewrite/RewriteValve.java
@@ -24,10 +24,10 @@ import java.io.StringReader;
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
 
 import jakarta.servlet.ServletException;
 import jakarta.servlet.http.Cookie;
@@ -102,7 +102,7 @@ public class RewriteValve extends ValveBase {
 /**
  * Maps to be used by the rules.
  */
-protected Map maps = new Hashtable<>();
+protected Map maps = new ConcurrentHashMap<>();
 
 
 /**


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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-15 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 9741030e386d6734854a411a1987266549804e8e
Author: Mark Thomas 
AuthorDate: Thu Sep 15 15:40:00 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/jakarta/servlet/jsp/tagext/TagSupport.java | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/jakarta/servlet/jsp/tagext/TagSupport.java 
b/java/jakarta/servlet/jsp/tagext/TagSupport.java
index b604bf0594..8cc2fca9e2 100644
--- a/java/jakarta/servlet/jsp/tagext/TagSupport.java
+++ b/java/jakarta/servlet/jsp/tagext/TagSupport.java
@@ -17,8 +17,10 @@
 package jakarta.servlet.jsp.tagext;
 
 import java.io.Serializable;
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import jakarta.servlet.jsp.JspException;
 import jakarta.servlet.jsp.PageContext;
@@ -227,7 +229,7 @@ public class TagSupport implements IterationTag, 
Serializable {
  */
 public void setValue(String k, Object o) {
 if (values == null) {
-values = new Hashtable<>();
+values = new ConcurrentHashMap<>();
 }
 values.put(k, o);
 }
@@ -266,7 +268,7 @@ public class TagSupport implements IterationTag, 
Serializable {
 if (values == null) {
 return null;
 }
-return values.keys();
+return Collections.enumeration(values.keySet());
 }
 
 /**
@@ -277,7 +279,7 @@ public class TagSupport implements IterationTag, 
Serializable {
 /**
  * Map of object values keyed by Strings for this tag.
  */
-private Hashtable values;
+private Map values;
 
 /**
  * The value of the id attribute of this tag; or null.


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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-14 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit d55ac6ef92e858082498d8882b36f8cb968e5a57
Author: Mark Thomas 
AuthorDate: Wed Sep 14 19:44:37 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/catalina/tribes/util/StringManager.java | 5 ++---
 java/org/apache/naming/StringManager.java   | 6 +++---
 java/org/apache/tomcat/util/res/StringManager.java  | 5 ++---
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/tribes/util/StringManager.java 
b/java/org/apache/catalina/tribes/util/StringManager.java
index aeb82f4235..0a60c94366 100644
--- a/java/org/apache/catalina/tribes/util/StringManager.java
+++ b/java/org/apache/catalina/tribes/util/StringManager.java
@@ -18,7 +18,7 @@ package org.apache.catalina.tribes.util;
 
 import java.text.MessageFormat;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -180,8 +180,7 @@ public class StringManager {
 // STATIC SUPPORT METHODS
 // --
 
-private static final Map> managers =
-new Hashtable<>();
+private static final Map> managers = new 
HashMap<>();
 
 
 /**
diff --git a/java/org/apache/naming/StringManager.java 
b/java/org/apache/naming/StringManager.java
index 0a4c3699ce..b20094d071 100644
--- a/java/org/apache/naming/StringManager.java
+++ b/java/org/apache/naming/StringManager.java
@@ -17,8 +17,9 @@
 package org.apache.naming;
 
 import java.text.MessageFormat;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
@@ -155,8 +156,7 @@ public class StringManager {
 // STATIC SUPPORT METHODS
 // --
 
-private static final Hashtable managers =
-new Hashtable<>();
+private static final Map managers = new HashMap<>();
 
 /**
  * Get the StringManager for a particular package. If a manager for
diff --git a/java/org/apache/tomcat/util/res/StringManager.java 
b/java/org/apache/tomcat/util/res/StringManager.java
index 17132b3d5e..ce68dc9827 100644
--- a/java/org/apache/tomcat/util/res/StringManager.java
+++ b/java/org/apache/tomcat/util/res/StringManager.java
@@ -18,7 +18,7 @@ package org.apache.tomcat.util.res;
 
 import java.text.MessageFormat;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -187,8 +187,7 @@ public class StringManager {
 // STATIC SUPPORT METHODS
 // --
 
-private static final Map> managers =
-new Hashtable<>();
+private static final Map> managers = new 
HashMap<>();
 
 
 /**


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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-14 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 1115f37ada93fd6e07511604ed857eecdbd7882a
Author: Mark Thomas 
AuthorDate: Wed Sep 14 19:29:18 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/catalina/startup/HomesUserDatabase.java  | 10 ++
 java/org/apache/catalina/startup/PasswdUserDatabase.java | 12 +++-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/startup/HomesUserDatabase.java 
b/java/org/apache/catalina/startup/HomesUserDatabase.java
index bbcb090d20..a0be2dbc5f 100644
--- a/java/org/apache/catalina/startup/HomesUserDatabase.java
+++ b/java/org/apache/catalina/startup/HomesUserDatabase.java
@@ -17,8 +17,10 @@
 package org.apache.catalina.startup;
 
 import java.io.File;
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Concrete implementation of the UserDatabase interface
@@ -32,7 +34,7 @@ public final class HomesUserDatabase implements UserDatabase {
 /**
  * The set of home directories for all defined users, keyed by username.
  */
-private final Hashtable homes = new Hashtable<>();
+private final Map homes = new HashMap<>();
 
 /**
  * The UserConfig listener with which we are associated.
@@ -73,11 +75,11 @@ public final class HomesUserDatabase implements 
UserDatabase {
 
 
 /**
- * Return an enumeration of the usernames defined on this server.
+ * Return an enumeration of the user names defined on this server.
  */
 @Override
 public Enumeration getUsers() {
-return homes.keys();
+return Collections.enumeration(homes.keySet());
 }
 
 
diff --git a/java/org/apache/catalina/startup/PasswdUserDatabase.java 
b/java/org/apache/catalina/startup/PasswdUserDatabase.java
index 893557ad81..3cfc9f7fd1 100644
--- a/java/org/apache/catalina/startup/PasswdUserDatabase.java
+++ b/java/org/apache/catalina/startup/PasswdUserDatabase.java
@@ -18,8 +18,10 @@ package org.apache.catalina.startup;
 
 import java.io.BufferedReader;
 import java.io.FileReader;
+import java.util.Collections;
 import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -43,9 +45,9 @@ public final class PasswdUserDatabase implements UserDatabase 
{
 
 
 /**
- * The set of home directories for all defined users, keyed by username.
+ * The set of home directories for all defined users, keyed by user name.
  */
-private final Hashtable homes = new Hashtable<>();
+private final Map homes = new HashMap<>();
 
 
 /**
@@ -87,11 +89,11 @@ public final class PasswdUserDatabase implements 
UserDatabase {
 
 
 /**
- * Return an enumeration of the usernames defined on this server.
+ * Return an enumeration of the user names defined on this server.
  */
 @Override
 public Enumeration getUsers() {
-return homes.keys();
+return Collections.enumeration(homes.keySet());
 }
 
 


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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-14 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 1b2509fe08b68eedb90398d14e65a9a24f45c740
Author: Mark Thomas 
AuthorDate: Wed Sep 14 19:22:43 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 java/org/apache/catalina/ha/session/DeltaSession.java | 3 +--
 java/org/apache/catalina/session/StandardSession.java | 5 ++---
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 968f02272c..1b0e9a72d2 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -27,7 +27,6 @@ import java.io.Serializable;
 import java.io.WriteAbortedException;
 import java.security.Principal;
 import java.util.ArrayList;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -955,7 +954,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 if (notes == null) {
-notes = new Hashtable<>();
+notes = new ConcurrentHashMap<>();
 }
 activate();
 }
diff --git a/java/org/apache/catalina/session/StandardSession.java 
b/java/org/apache/catalina/session/StandardSession.java
index 8525072e3c..bd06046419 100644
--- a/java/org/apache/catalina/session/StandardSession.java
+++ b/java/org/apache/catalina/session/StandardSession.java
@@ -31,7 +31,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
-import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -206,7 +205,7 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
  * and event listeners.  IMPLEMENTATION NOTE: This object is
  * not saved and restored across session serializations!
  */
-protected transient Map notes = new Hashtable<>();
+protected transient Map notes = new ConcurrentHashMap<>();
 
 
 /**
@@ -1446,7 +1445,7 @@ public class StandardSession implements HttpSession, 
Session, Serializable {
 }
 
 if (notes == null) {
-notes = new Hashtable<>();
+notes = new ConcurrentHashMap<>();
 }
 /*
  * The next object read could either be the number of attributes


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



[tomcat] branch main updated: Refactor to avoid use of Hashtable. No functional change.

2022-09-14 Thread markt
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 04657ab7f215401f5afdefcc9a266862e1e48c87
Author: Mark Thomas 
AuthorDate: Wed Sep 14 19:18:47 2022 +0100

Refactor to avoid use of Hashtable. No functional change.
---
 webapps/examples/WEB-INF/classes/cal/Entries.java   |  7 ---
 webapps/examples/WEB-INF/classes/cal/TableBean.java | 19 ++-
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/webapps/examples/WEB-INF/classes/cal/Entries.java 
b/webapps/examples/WEB-INF/classes/cal/Entries.java
index f34f957a2f..5c6cd49888 100644
--- a/webapps/examples/WEB-INF/classes/cal/Entries.java
+++ b/webapps/examples/WEB-INF/classes/cal/Entries.java
@@ -16,19 +16,20 @@
  */
 package cal;
 
-import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import jakarta.servlet.http.HttpServletRequest;
 
 public class Entries {
 
-private final Hashtable entries;
+private final Map entries;
 private static final String[] time = { "8am", "9am", "10am", "11am",
 "12pm", "1pm", "2pm", "3pm", "4pm", "5pm", "6pm", "7pm", "8pm" };
 public static final int rows = 12;
 
 public Entries() {
-entries = new Hashtable<>(rows);
+entries = new ConcurrentHashMap<>(rows);
 for (int i = 0; i < rows; i++) {
 entries.put(time[i], new Entry(time[i]));
 }
diff --git a/webapps/examples/WEB-INF/classes/cal/TableBean.java 
b/webapps/examples/WEB-INF/classes/cal/TableBean.java
index 6e855e11bf..e7821257cf 100644
--- a/webapps/examples/WEB-INF/classes/cal/TableBean.java
+++ b/webapps/examples/WEB-INF/classes/cal/TableBean.java
@@ -16,22 +16,23 @@
  */
 package cal;
 
-import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import jakarta.servlet.http.HttpServletRequest;
 
 public class TableBean {
 
-final Hashtable table;
-final JspCalendar JspCal;
-Entries entries;
-String date;
-String name = null;
-String email = null;
-boolean processError = false;
+private final Map table;
+private final JspCalendar JspCal;
+private Entries entries;
+private String date;
+private String name = null;
+private String email = null;
+private boolean processError = false;
 
 public TableBean() {
-this.table = new Hashtable<>(10);
+this.table = new ConcurrentHashMap<>(10);
 this.JspCal = new JspCalendar();
 this.date = JspCal.getCurrentDate();
 }


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