Skip to content

Commit

Permalink
Override Timestamp hashCode for consistent hashing
Browse files Browse the repository at this point in the history
Timestamp's hashCode was based on the parameter dataTime which might have
a timezone != UTC. The consequence:

  val t = Timestamp.now
  t.hashCode != Timestamp(t.toString).hashCode

This patch overrides hashCode to use the UTC normalized time variable of the
Timestamp case class.

This probably fixes d2iq-archive#1082
  • Loading branch information
sttts committed Feb 18, 2015
1 parent e6cd021 commit e682fdc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/scala/mesosphere/marathon/state/Timestamp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ case class Timestamp(dateTime: DateTime) extends Ordered[Timestamp] {
case _ => false
}

override def hashCode: Int = time.hashCode

def compare(that: Timestamp): Int = this.time compareTo that.time

override def toString: String = time.toString
Expand Down

0 comments on commit e682fdc

Please sign in to comment.