Skip to content

Commit

Permalink
[Remove] Remaining Joda and Joda Dependency
Browse files Browse the repository at this point in the history
Joda was deprecated in Elasticsearch 7.x. OpenSearch should have
proactively removed in 2.0. This commit removes the remaining Joda
dependency and formatting logic in favor of java 8 time. It adds a
new LegacyFormat class, however, to ensure camelCase DateFormat is
supported for indexes created in ElasticSearch 7.x (and carried through
OpenSearch 1.x).

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed Oct 26, 2023
1 parent 5ae9333 commit 853e466
Show file tree
Hide file tree
Showing 60 changed files with 1,492 additions and 7,024 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

package org.opensearch.benchmark.time;

import org.opensearch.common.joda.Joda;
import org.opensearch.common.time.DateFormatter;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
Expand All @@ -56,15 +55,9 @@
public class DateFormatterBenchmark {

private final DateFormatter javaFormatter = DateFormatter.forPattern("8year_month_day||ordinal_date||epoch_millis");
private final DateFormatter jodaFormatter = Joda.forPattern("year_month_day||ordinal_date||epoch_millis");

@Benchmark
public TemporalAccessor parseJavaDate() {
return javaFormatter.parse("1234567890");
}

@Benchmark
public TemporalAccessor parseJodaDate() {
return jodaFormatter.parse("1234567890");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ java.util.concurrent.Future#cancel(boolean)
org.opensearch.common.io.PathUtils#get(java.lang.String, java.lang.String[])
org.opensearch.common.io.PathUtils#get(java.net.URI)

@defaultMessage Constructing a DateTime without a time zone is dangerous
org.joda.time.DateTime#<init>()
org.joda.time.DateTime#<init>(long)
org.joda.time.DateTime#<init>(int, int, int, int, int)
org.joda.time.DateTime#<init>(int, int, int, int, int, int)
org.joda.time.DateTime#<init>(int, int, int, int, int, int, int)
org.joda.time.DateTime#now()
org.joda.time.DateTimeZone#getDefault()

@defaultMessage Local times may be ambiguous or nonexistent in a specific time zones. Use ZoneRules#getValidOffsets() instead.
java.time.LocalDateTime#atZone(java.time.ZoneId)
java.time.ZonedDateTime#of(int, int, int, int, int, int, int, java.time.ZoneId)
Expand Down
1 change: 0 additions & 1 deletion buildSrc/version.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jakarta_annotation = 1.3.5
jna = 5.13.0

netty = 4.1.100.Final
joda = 2.12.2

# client dependencies
httpclient5 = 5.2.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,17 @@
import org.opensearch.script.Script;
import org.opensearch.script.ScriptType;
import org.opensearch.search.fetch.subphase.FetchSourceContext;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;

import java.io.IOException;
import java.time.LocalTime;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -1022,7 +1024,8 @@ private void validateBulkResponses(int nbItems, boolean[] errors, BulkResponse b
public void testUrlEncode() throws IOException {
String indexPattern = "<logstash-{now/M}>";
String expectedIndex = "logstash-"
+ DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(DateTimeZone.UTC).monthOfYear().roundFloorCopy());
+ DateTimeFormatter.ofPattern("uuuu.MM.dd", Locale.ROOT)
.format(ZonedDateTime.now(ZoneOffset.UTC).withDayOfMonth(1).with(LocalTime.MIN));
{
IndexRequest indexRequest = new IndexRequest(indexPattern).id("id#1");
indexRequest.source("field", "value");
Expand Down
Loading

0 comments on commit 853e466

Please sign in to comment.