Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Use ROOT Locale for Strings #14

Merged
merged 1 commit into from
Jun 14, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.HashSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;

Expand Down Expand Up @@ -59,7 +60,9 @@ public class IntervalSchedule implements Schedule {

public IntervalSchedule(Instant startTime, int interval, ChronoUnit unit) {
if (!SUPPORTED_UNITS.contains(unit)) {
throw new IllegalArgumentException(String.format("Interval unit %s is not supported, expects %s", unit, SUPPORTED_UNITS));
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Interval unit %s is not supported, expects %s",
unit, SUPPORTED_UNITS));
}
this.startTime = startTime;
this.interval = interval;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Locale;

/**
* Schedule XContent parser.
Expand All @@ -43,7 +44,9 @@ public static Schedule parse(XContentParser parser) throws IOException {
switch (cronField) {
case CronSchedule.EXPRESSION_FIELD: expression = parser.text(); break;
case CronSchedule.TIMEZONE_FIELD: timezone = ZoneId.of(parser.text()); break;
default: throw new IllegalArgumentException(String.format("Unknown cron field %s", cronField));
default:
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Unknown cron field %s", cronField));
}
}
XContentParserUtils.ensureExpectedToken(XContentParser.Token.END_OBJECT, parser.currentToken(), parser::getTokenLocation);
Expand All @@ -59,14 +62,18 @@ public static Schedule parse(XContentParser parser) throws IOException {
switch (intervalField) {
case IntervalSchedule.START_TIME_FIELD: startTime = Instant.ofEpochMilli(parser.longValue()); break;
case IntervalSchedule.PERIOD_FIELD: period = parser.intValue(); break;
case IntervalSchedule.UNIT_FIELD: unit = ChronoUnit.valueOf(parser.text().toUpperCase()); break;
default: throw new IllegalArgumentException(String.format("Unknown interval field %s", intervalField));
case IntervalSchedule.UNIT_FIELD: unit = ChronoUnit.valueOf(parser.text().toUpperCase(Locale.ROOT)); break;
default:
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Unknown interval field %s", intervalField));
}
}
XContentParserUtils.ensureExpectedToken(XContentParser.Token.END_OBJECT, parser.currentToken(), parser::getTokenLocation);
parser.nextToken();
return new IntervalSchedule(startTime, period, unit);
default: throw new IllegalArgumentException(String.format("Unknown schedule type %s", fieldName));
default:
throw new IllegalArgumentException(
String.format(Locale.ROOT, "Unknown schedule type %s", fieldName));
}
}
throw new IllegalArgumentException("Invalid schedule document object.");
Expand Down