-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SOLR-17379: Fix date parsing in Java 23, remove Lucene TestSecurityManager #3154
Merged
HoustonPutman
merged 4 commits into
apache:main
from
HoustonPutman:fix-field-parsing-tests
Feb 4, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
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 void testAKSTZone() throws IOException { | |
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?!) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice clean up |
||
// 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 { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance that this pattern shows up anywhere else and or is suggested in docs? Magic system variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, clearly it didn't work haha.