Skip to content

Commit 8ac8e01

Browse files
kanoshiouBogdan Pintea
andauthored
Apply suggestions from code review
Co-authored-by: Bogdan Pintea <[email protected]>
1 parent 9ad78d4 commit 8ac8e01

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

server/src/main/java/org/elasticsearch/common/Rounding.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ long extraLocalOffsetLookup() {
8383
private final long extraLocalOffsetLookup = TimeUnit.DAYS.toMillis(92);
8484

8585
long roundFloor(long utcMillis, int multiplier) {
86-
if (multiplier == 1) {
87-
return DateUtils.roundQuarterOfYear(utcMillis);
88-
}
89-
return DateUtils.roundIntervalMonthOfYear(utcMillis, multiplier * 3);
86+
return multiplier == 1
87+
? DateUtils.roundQuarterOfYear(utcMillis)
88+
: DateUtils.roundIntervalMonthOfYear(utcMillis, multiplier * 3);
9089
}
9190

9291
long extraLocalOffsetLookup() {

server/src/main/java/org/elasticsearch/common/time/DateUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static long roundMonthOfYear(final long utcMillis) {
374374
*/
375375
public static long roundIntervalMonthOfYear(final long utcMillis, final int monthInterval) {
376376
if (monthInterval <= 0) {
377-
throw new IllegalArgumentException("month interval [" + monthInterval + "] must be positive");
377+
throw new IllegalArgumentException("month interval must be strictly positive, got [" + monthInterval + "]");
378378
}
379379
int year = getYear(utcMillis);
380380
int month = getMonthOfYear(utcMillis, year);
@@ -403,7 +403,7 @@ public static long roundYearInterval(final long utcMillis, final int yearInterva
403403
throw new IllegalArgumentException("year interval [" + yearInterval + "] must be positive");
404404
}
405405
int year = getYear(utcMillis);
406-
return utcMillisAtStartOfYear((year - 1) / yearInterval * yearInterval + 1);
406+
return utcMillisAtStartOfYear(((year - 1) / yearInterval) * yearInterval + 1);
407407
}
408408

409409
/**

0 commit comments

Comments
 (0)