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

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


The following commit(s) were added to refs/heads/main by this push:
     new b779ed0590e SOLR-17379: Fix date parsing in Java 23, remove Lucene 
TestSecurityManager (#3154)
b779ed0590e is described below

commit b779ed0590e36f69f7d1ce17e99dc936ab46752f
Author: Houston Putman <[email protected]>
AuthorDate: Tue Feb 4 11:36:45 2025 -0800

    SOLR-17379: Fix date parsing in Java 23, remove Lucene TestSecurityManager 
(#3154)
    
    * Fix system exit in test
    
    Co-authored-by: Chris Hostetter <[email protected]>
---
 gradle/testing/randomization.gradle                |  2 +-
 .../ParseDateFieldUpdateProcessorFactory.java      |  8 +++-
 .../solr/security/BasicAuthIntegrationTest.java    |  4 +-
 .../ParsingFieldUpdateProcessorsTest.java          | 55 ++++++++++------------
 4 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/gradle/testing/randomization.gradle 
b/gradle/testing/randomization.gradle
index d3ae962c144..6d2cb2791ac 100644
--- a/gradle/testing/randomization.gradle
+++ b/gradle/testing/randomization.gradle
@@ -213,7 +213,7 @@ allprojects {
                   javaSecurityPolicy: javaSecurityPolicy
               )
           )
-          systemProperty 'java.security.manager', 
"org.apache.lucene.tests.util.TestSecurityManager"
+          systemProperty 'java.security.manager', "default"
 
           def gradleUserHome = project.gradle.getGradleUserHomeDir()
           systemProperty 'gradle.lib.dir', 
Paths.get(project.class.location.toURI()).parent.toAbsolutePath().toString().replace('\\',
 '/')
diff --git 
a/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
 
b/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
index f06f4a4af68..69b9af7e990 100644
--- 
a/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
+++ 
b/solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java
@@ -186,7 +186,13 @@ public class ParseDateFieldUpdateProcessorFactory extends 
FieldMutatingUpdatePro
           return Date.from(parseInstant(parser, srcStringVal, parsePosition));
         } catch (DateTimeParseException e) {
           if (log.isDebugEnabled()) {
-            log.debug("value '{}' is not parseable with format '{}'", 
srcStringVal, parser);
+            log.debug(
+                "value '{}' is not parseable with format '{}' (using {} + {})",
+                srcStringVal,
+                parser,
+                parser.getLocale(),
+                parser.getZone(),
+                e);
           }
         }
       }
diff --git 
a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java 
b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java
index 281c6475611..4c7c5aa7c27 100644
--- a/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/security/BasicAuthIntegrationTest.java
@@ -295,12 +295,12 @@ public class BasicAuthIntegrationTest extends 
SolrCloudAuthTestCase {
       verifySecurityStatus(cl, baseUrl + "/admin/info/key", "key", 
NOT_NULL_PREDICATE, 20);
       assertAuthMetricsMinimums(17, 8, 8, 1, 0, 0);
 
-      String[] toolArgs = new String[] {"status", "--solr-url", baseUrl};
+      String[] toolArgs =
+          new String[] {"status", "--solr-url", baseUrl, "--credentials", 
"harry:HarryIsUberCool"};
       ByteArrayOutputStream baos = new ByteArrayOutputStream();
       PrintStream stdoutSim = new PrintStream(baos, true, 
StandardCharsets.UTF_8.name());
       StatusTool tool = new StatusTool(stdoutSim);
       try {
-        System.setProperty("basicauth", "harry:HarryIsUberCool");
         tool.runTool(SolrCLI.processCommandLineArgs(tool, toolArgs));
         Map<?, ?> obj = (Map<?, ?>) Utils.fromJSON(new 
ByteArrayInputStream(baos.toByteArray()));
         assertTrue(obj.containsKey("version"));
diff --git 
a/solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java
 
b/solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java
index 7e78a49da9c..c19aeaf516a 100644
--- 
a/solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java
+++ 
b/solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java
@@ -26,6 +26,7 @@ import java.time.ZoneId;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
 import java.time.temporal.TemporalAccessor;
 import java.util.Date;
 import java.util.HashMap;
@@ -1064,43 +1065,37 @@ public class ParsingFieldUpdateProcessorsTest extends 
UpdateProcessorTestBase {
     final String inputString = "Thu Nov 13 04:35:51 AKST 2008"; // asctime + 
timezone1
 
     final long expectTs = 1226583351000L;
-    assertEquals(
-        expectTs,
-        DateTimeFormatter.ofPattern(dateFormat, Locale.ENGLISH)
-            .withZone(ZoneId.of("UTC"))
-            .parse(inputString, Instant::from)
-            .toEpochMilli());
 
-    // ensure english locale and root locale return the same date
-    assertEquals(
-        expectTs + "",
-        DateTimeFormatter.ofPattern(dateFormat, Locale.ENGLISH)
-            .withZone(ZoneId.of("UTC"))
-            .parse(inputString, Instant::from)
-            .toEpochMilli(),
-        DateTimeFormatter.ofPattern(dateFormat, Locale.ROOT)
-            .withZone(ZoneId.of("UTC"))
-            .parse(inputString, Instant::from)
-            .toEpochMilli());
+    try {
+      // ensure english locale and root locale return the same date
+      assertEquals(
+          expectTs,
+          DateTimeFormatter.ofPattern(dateFormat, Locale.ENGLISH)
+              .withZone(ZoneId.of("UTC"))
+              .parse(inputString, Instant::from)
+              .toEpochMilli());
+
+      assertEquals(
+          expectTs,
+          DateTimeFormatter.ofPattern(dateFormat, Locale.ROOT)
+              .withZone(ZoneId.of("UTC"))
+              .parse(inputString, Instant::from)
+              .toEpochMilli());
+    } catch (DateTimeParseException e) {
+      // If the JVM's java.locale.providers can't parse these, there is no 
hope of this test passing
+      assumeNoException("JVM's Locale provider is incompatible with this 
test", e);
+    }
 
     assertParsedDate(
         inputString,
         Date.from(Instant.ofEpochMilli(expectTs)),
         "parse-date-patterns-default-config");
 
-    // A bug in Java 9 (not in 8) causes this to fail!  (not fixed yet?!)
-    // see https://bugs.openjdk.java.net/browse/JDK-8189784
-    if (System.getProperty("java.version").startsWith("1.8.")) {
-      // with daylight savings time timezone
-      assertParsedDate(
-          "Fri Oct 7 05:14:15 AKDT 2005",
-          Date.from(inst20051007131415()),
-          "parse-date-patterns-default-config");
-    } else {
-      System.err.println(
-          "Didn't test AKDT because only Java 1.8 does this right!  This Java 
version is: "
-              + System.getProperty("java.version"));
-    }
+    // with daylight savings time timezone
+    assertParsedDate(
+        "Fri Oct 7 05:14:15 AKDT 2005",
+        Date.from(inst20051007131415()),
+        "parse-date-patterns-default-config");
   }
 
   public void testEDTZone() throws IOException {

Reply via email to