You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2026/03/23 20:14:49 UTC

(lucene) branch main updated: Fix luke terms export failure on Windows when field names contain characters forbidden in file name (#15838)

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

dweiss 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 149881f0799 Fix luke terms export failure on Windows when field names contain characters forbidden in file name (#15838)
149881f0799 is described below

commit 149881f0799ba160ce64c54a789a83daeeea859c
Author: gaobinlong <gb...@amazon.com>
AuthorDate: Tue Mar 24 04:14:42 2026 +0800

    Fix luke terms export failure on Windows when field names contain characters forbidden in file name (#15838)
    
    * Fix luke terms export failure on Windows when field names contain characters forbidden in file name
    
    Signed-off-by: Binlong Gao <gb...@amazon.com>
    
    * Refactor test code
    
    Signed-off-by: Binlong Gao <gb...@amazon.com>
    
    * Modify PR number in change log
    
    Signed-off-by: Binlong Gao <gb...@amazon.com>
    
    * Remove test code
    
    Signed-off-by: Binlong Gao <gb...@amazon.com>
    
    ---------
    
    Signed-off-by: Binlong Gao <gb...@amazon.com>
---
 lucene/CHANGES.txt                                                   | 2 ++
 .../src/java/org/apache/lucene/luke/models/tools/IndexToolsImpl.java | 5 ++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index d96058f1e63..b69e8ddafc6 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -156,6 +156,8 @@ Bug Fixes
 * GITHUB#14971: Fix CachedExecutor thread pool leak in ConcurrentMergeScheduler
   when IndexWriter initialization fails. (Su Beom)
 
+* GITHUB#15838: Fix luke terms export failure on Windows when field names contain characters forbidden in file name (Binlong Gao)
+
 Changes in Runtime Behavior
 ---------------------
 * GITHUB#14187: The query cache is now disabled by default. (Adrien Grand)
diff --git a/lucene/luke/src/java/org/apache/lucene/luke/models/tools/IndexToolsImpl.java b/lucene/luke/src/java/org/apache/lucene/luke/models/tools/IndexToolsImpl.java
index 8d76e9e6739..151b06b07ef 100644
--- a/lucene/luke/src/java/org/apache/lucene/luke/models/tools/IndexToolsImpl.java
+++ b/lucene/luke/src/java/org/apache/lucene/luke/models/tools/IndexToolsImpl.java
@@ -199,7 +199,10 @@ public final class IndexToolsImpl extends LukeModel implements IndexTools {
 
   @Override
   public String exportTerms(String destDir, String field, String delimiter) {
-    String filename = "terms_" + field + "_" + System.currentTimeMillis() + ".out";
+    // Sanitize field name for use in file name: replace forbidden characters on Windows
+    // (< > : " /\ | ? *) with '_' to avoid file creation failure.
+    String sanitizedFieldName = field.replaceAll("[<>:\"/\\\\|?*]", "_");
+    String filename = "terms_" + sanitizedFieldName + "_" + System.currentTimeMillis() + ".out";
     Path path = Paths.get(destDir, filename);
     try {
       Terms terms = MultiTerms.getTerms(reader, field);