You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2026/02/10 10:49:51 UTC

(lucene) branch main updated: Forbid java.util.Hashtable (#15688)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new ca4903f739d Forbid java.util.Hashtable (#15688)
ca4903f739d is described below

commit ca4903f739d09a12ccc44536006b8ede3ed12ce6
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Tue Feb 10 11:49:45 2026 +0100

    Forbid java.util.Hashtable (#15688)
    
    Closes #15685
---
 .../apache/lucene/gradle/plugins/ide/EclipseSupportPlugin.java    | 8 +++++++-
 gradle/validation/forbidden-apis/all/defaults.txt                 | 8 +++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/ide/EclipseSupportPlugin.java b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/ide/EclipseSupportPlugin.java
index 1a4b1744277..b72f0888ba8 100644
--- a/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/ide/EclipseSupportPlugin.java
+++ b/build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/ide/EclipseSupportPlugin.java
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Stream;
+import org.apache.lucene.gradle.SuppressForbidden;
 import org.apache.lucene.gradle.plugins.LuceneGradlePlugin;
 import org.apache.lucene.gradle.plugins.java.EcjLintPlugin;
 import org.apache.tools.ant.filters.ReplaceTokens;
@@ -74,6 +75,11 @@ public class EclipseSupportPlugin extends LuceneGradlePlugin {
     }
   }
 
+  @SuppressForbidden(reason = "Ant's ReplaceTokens filter requires a Hashtable as parameter")
+  private static <K, V> Hashtable<K, V> newHashtable(Map<K, V> map) {
+    return new Hashtable<>(map);
+  }
+
   private void configureEclipseIdeSettings(Project project, String eclipseJavaVersion) {
     var plugins = project.getPlugins();
     plugins.apply("java-base");
@@ -120,7 +126,7 @@ public class EclipseSupportPlugin extends LuceneGradlePlugin {
                   task.filter(
                       Map.of(
                           "tokens",
-                          new Hashtable<>(
+                          newHashtable(
                               Map.ofEntries(
                                   Map.entry("eclipseJavaVersion", eclipseJavaVersion),
                                   Map.entry("ecj-lint-config", ecjLintProps)))),
diff --git a/gradle/validation/forbidden-apis/all/defaults.txt b/gradle/validation/forbidden-apis/all/defaults.txt
index 6aaad7f2903..fe4ab293e47 100644
--- a/gradle/validation/forbidden-apis/all/defaults.txt
+++ b/gradle/validation/forbidden-apis/all/defaults.txt
@@ -39,11 +39,9 @@ java.lang.Character#codePointAt(char[],int) @ Implicit end offset is error-prone
 java.io.File#delete() @ use Files.delete for real exception, IOUtils.deleteFilesIgnoringExceptions if you dont care
 
 java.util.Collections#shuffle(java.util.List) @ Use shuffle(List, Random) instead so that it can be reproduced
-java.util.Stack @ Use more modern java.util.ArrayDeque as it is not synchronized
-java.util.Vector @ Use more modern java.util.ArrayList as it is not synchronized
-
-# TODO (needs some fix in forbiddenapis): this also hits java.util.Properties:
-# java.util.Hashtable @ Use more modern java.util.HashMap as it is not synchronized
+java.util.Stack#<init>(**) @ Use more modern java.util.ArrayDeque as it is not synchronized
+java.util.Vector#<init>(**) @ Use more modern java.util.ArrayList as it is not synchronized
+java.util.Hashtable#<init>(**) @ Use more modern java.util.HashMap as it is not synchronized
 
 java.util.Locale#forLanguageTag(java.lang.String) @ use new Locale.Builder().setLanguageTag(...).build() which has error handling
 java.util.Locale#toString() @ use Locale#toLanguageTag() for a standardized BCP47 locale name