-
Notifications
You must be signed in to change notification settings - Fork 210
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
Cleanup after UI migration, updated docs, fixed retransmission bug #1786
Conversation
} | ||
|
||
private void initializeTimestamps(String startTimestamp, String endTimestamp) { | ||
if (startTimestamp == null || endTimestamp == null) { |
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.
question: If only one timestamp (either start or end) is null, then both properties should have null value?
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.
Actually it doesn't matter, because the validation will evoke 400 from an endpoint with message that timestamp cannot be null.
try { | ||
this.startTimestamp = Instant.parse(startTimestamp); | ||
this.endTimestamp = Instant.parse(endTimestamp); | ||
} catch (Exception e) { |
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.
suggestion: Catching Exception
can be too wide in this case - DateTimeParseException
could be a better fit.
this.startTimestamp = Instant.from(DateTimeFormatter.ofPattern(ALTERNATE_DATE_FORMAT) | ||
.withZone(ZoneId.of("UTC")) | ||
.parse(startTimestamp)); | ||
this.endTimestamp = Instant.from(DateTimeFormatter.ofPattern(ALTERNATE_DATE_FORMAT) |
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.
suggestion: Remove code repetition by extracting DateTimeFormatter
creation to private final
value.
initializeTimestamps(startTimestamp, endTimestamp); | ||
} | ||
|
||
private void initializeTimestamps(String startTimestamp, String endTimestamp) { |
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.
suggestion: I've refactored this method to:
private void initializeTimestamps(String startTimestamp, String endTimestamp) {
if (startTimestamp == null || endTimestamp == null) {
this.startTimestamp = null;
this.endTimestamp = null;
return;
}
for (DateTimeFormatter formatter : formatters) {
try {
this.startTimestamp = formatter.parse(startTimestamp, Instant::from);
this.endTimestamp = formatter.parse(endTimestamp, Instant::from);
break;
} catch (DateTimeParseException ignored) {}
}
}
where formatters
is:
private final List<DateTimeFormatter> formatters = List.of(
DateTimeFormatter.ISO_INSTANT,
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'").withZone(ZoneId.of("UTC"))
);
What do you think about it?
|
||
private void initializeTimestamps(String startTimestamp, String endTimestamp) { | ||
if (startTimestamp == null || endTimestamp == null) { | ||
this.startTimestamp = null; |
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.
Aren't lines 45 and 46 redundant?
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.
Thats right, we could just assign one of them and the validation will fail, but I decided to do it for both to be more consistent and clear.
No description provided.