-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[ErrorProne] JodaConstructors check - Use JodaTime's static factories instead of the ambiguous constructors. #37744
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
Changes from all commits
e2409df
f23a05e
06edbf0
b21b5c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -802,21 +802,21 @@ public static void main(String[] args) { | |
| Create.timestamped( | ||
| TimestampedValue.of( | ||
| new TableRow().set("user", "mobile").set("score", 12).set("gap", 5), | ||
| new Instant()), | ||
| Instant.now()), | ||
| TimestampedValue.of( | ||
| new TableRow().set("user", "desktop").set("score", 4), new Instant()), | ||
| new TableRow().set("user", "desktop").set("score", 4), Instant.now()), | ||
| TimestampedValue.of( | ||
| new TableRow().set("user", "mobile").set("score", -3).set("gap", 5), | ||
| new Instant().plus(Duration.millis(2000))), | ||
| Instant.now().plus(Duration.millis(2000))), | ||
| TimestampedValue.of( | ||
| new TableRow().set("user", "mobile").set("score", 2).set("gap", 5), | ||
| new Instant().plus(Duration.millis(9000))), | ||
| Instant.now().plus(Duration.millis(9000))), | ||
| TimestampedValue.of( | ||
| new TableRow().set("user", "mobile").set("score", 7).set("gap", 5), | ||
| new Instant().plus(Duration.millis(12000))), | ||
| Instant.now().plus(Duration.millis(12000))), | ||
| TimestampedValue.of( | ||
| new TableRow().set("user", "desktop").set("score", 10), | ||
| new Instant().plus(Duration.millis(12000))))); | ||
| Instant.now().plus(Duration.millis(12000))))); | ||
|
Comment on lines
803
to
+819
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are multiple calls to final Instant now = Instant.now();
PCollection<TableRow> pc =
p.apply(
"Create Events",
Create.timestamped(
TimestampedValue.of(
new TableRow().set("user", "mobile").set("score", 12).set("gap", 5),
now),
TimestampedValue.of(
new TableRow().set("user", "desktop").set("score", 4), now),
TimestampedValue.of(
new TableRow().set("user", "mobile").set("score", -3).set("gap", 5),
now.plus(Duration.millis(2000))),
// ... and so on
)); |
||
| // [END CustomSessionWindow5] | ||
|
|
||
| // [START CustomSessionWindow6] | ||
|
|
||
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.
Calling
Instant.now()multiple times within the same expression can lead to inconsistencies if the system clock ticks between the calls. It's safer to call it once and store the result in a local variable before using it. For example: