Skip to content
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

chore: remove Joda-Time dependency from maestro-common #25 #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion maestro-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dependencies {
implementation javaxValidationDep
implementation jacksonYamlDep
implementation quartzDep
implementation jodaTimeDep
implementation(cronutilsDep) {
exclude group: 'org.glassfish'
}
Expand Down
1 change: 0 additions & 1 deletion maestro-common/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ com.mchange:mchange-commons-java:0.2.15=compileClasspath
com.zaxxer:HikariCP-java7:2.4.13=compileClasspath
javax.inject:javax.inject:1=compileClasspath
javax.validation:validation-api:2.0.1.Final=compileClasspath
joda-time:joda-time:2.10.14=compileClasspath
org.projectlombok:lombok:1.18.34=annotationProcessor,compileClasspath
org.quartz-scheduler:quartz:2.3.2=compileClasspath
org.slf4j:slf4j-api:1.7.30=compileClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.netflix.maestro.models.instance.RunPolicy;
import com.netflix.maestro.models.instance.StepInstance;
import com.netflix.maestro.models.parameter.ParamMode;
import java.time.ZoneId;
import java.util.TimeZone;
import org.joda.time.DateTimeZone;

/** Class to hold the user facing default values for unset fields. */
public final class Defaults {
Expand Down Expand Up @@ -103,7 +103,7 @@ private Defaults() {}
StepInstance.Status.NOT_CREATED;

/** Default Time Zone. * */
public static final TimeZone DEFAULT_TIMEZONE = DateTimeZone.UTC.toTimeZone();
public static final TimeZone DEFAULT_TIMEZONE = TimeZone.getTimeZone(ZoneId.of("UTC"));

/** Default Param Mode. */
public static final ParamMode DEFAULT_PARAM_MODE = ParamMode.MUTABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.netflix.maestro.models.trigger.TimeTrigger;
import com.netflix.maestro.models.trigger.TimeTriggerWithJitter;
import java.text.ParseException;
import java.time.ZoneId;
import java.util.Date;
import java.util.Optional;
import java.util.Random;
Expand All @@ -31,7 +32,6 @@
import java.util.concurrent.ThreadLocalRandom;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTimeZone;
import org.quartz.CronExpression;

/** Cron Helper utility class. * */
Expand Down Expand Up @@ -60,7 +60,7 @@ public static CronExpression buildCron(String cron) throws ParseException {
* @throws ParseException parse error
*/
public static CronExpression buildCron(String cron, String timezone) throws ParseException {
return buildCron(cron, DateTimeZone.forID(timezone).toTimeZone());
return buildCron(cron, TimeZone.getTimeZone(ZoneId.of(timezone)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.time.ZoneId;
import java.util.Set;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.Payload;
import org.joda.time.DateTimeZone;

/** Maestro timezone expression validation. */
@Documented
Expand All @@ -40,6 +41,8 @@

/** Maestro timezone validator. */
class TimeZoneValidator implements ConstraintValidator<TimeZoneConstraint, String> {
private static final Set<String> AVAILABLE_ZONE_IDS = ZoneId.getAvailableZoneIds();

@Override
public void initialize(TimeZoneConstraint constraint) {}

Expand All @@ -49,14 +52,13 @@ public boolean isValid(String timezone, ConstraintValidatorContext context) {
return true;
}

try {
DateTimeZone.forID(timezone);
} catch (IllegalArgumentException e) {
if (!AVAILABLE_ZONE_IDS.contains(timezone)) {
context
.buildConstraintViolationWithTemplate("[timezone expression] is not valid: " + e)
.buildConstraintViolationWithTemplate("[timezone expression] is not valid: " + timezone)
.addConstraintViolation();
return false;
}

return true;
}
}
Expand Down