Github user srdo commented on a diff in the pull request:
https://github.com/apache/storm/pull/1924#discussion_r106687191
--- Diff:
external/storm-kafka-client/src/main/java/org/apache/storm/kafka/spout/KafkaSpoutRetryExponentialBackoff.java
---
@@ -54,21 +55,28 @@
private static class RetryEntryTimeStampComparator implements
Serializable, Comparator<RetrySchedule> {
@Override
public int compare(RetrySchedule entry1, RetrySchedule entry2) {
- return
Long.valueOf(entry1.nextRetryTimeNanos()).compareTo(entry2.nextRetryTimeNanos());
+ int result =
Long.valueOf(entry1.nextRetryTimeNanos()).compareTo(entry2.nextRetryTimeNanos());
+
+ if(result == 0) {
+ //TreeSet uses compareTo instead of equals() for the Set
contract
+ //Ensure that we can save two retry schedules with the
same timestamp
--- End diff --
It's probably impossible in real life if System.nanoTime has sufficiently
high resolution (not guaranteed to be any better than
System.currentTimeMillis), but it can happen in tests that use simulated time.
There's still potential for collisions if two retry schedules happen to have
the same hashCode and timestamp, but that's very unlikely. I mostly made the
change for the benefit of the tests, but it doesn't hurt to reduce the chance
of collision in general.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---