You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/09/14 18:19:18 UTC

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

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

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


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

commit 8ab37d8c0dfb5609d4e6b68755c8c21f06bebb0b
Author: Mark Thomas <ma...@apache.org>
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 4b3a5ee1e3..cac611a03b 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 javax.servlet.http.HttpServletRequest;
 
 public class Entries {
 
-    private final Hashtable<String, Entry> entries;
+    private final Map<String, Entry> 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 1a871ae28b..9f1cc4a6cf 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 javax.servlet.http.HttpServletRequest;
 
 public class TableBean {
 
-    final Hashtable<String, Entries> table;
-    final JspCalendar JspCal;
-    Entries entries;
-    String date;
-    String name = null;
-    String email = null;
-    boolean processError = false;
+    private final Map<String, Entries> 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org