package com.twitter.server.internal

import com.twitter.finagle.stats.StatsReceiver
import com.twitter.inject.{Injector, Logging}
import scala.util.control.NonFatal

object FinagleBuildRevision extends Logging {

  def register(injector: Injector): Unit = {
    com.twitter.finagle.Init.finagleBuildRevision match {
      case "?" =>
        warn("Unable to resolve Finagle revision.")
      case revision =>
        debug(s"Resolved Finagle build revision: (rev=$revision)")
        injector.instance[StatsReceiver].scope("finagle").provideGauge("build/revision") {
          convertBuildRevision(revision).toFloat
        }
    }
  }

  /* Private */

  private[server] def convertBuildRevision(revision: String): Long = {
    try {
      java.lang.Long.parseUnsignedLong(revision.take(10), 16)
    } catch {
      case NonFatal(e) =>
        error(s"Unable to convert Finagle build revision to long: ${e.getMessage}")
        -1L
    }
  }
}

package com.twitter.server.internal

import com.twitter.finagle.stats.StatsReceiver
import com.twitter.inject.{Injector, Logging}
import scala.util.control.NonFatal
import com.twitter.util.U64._

object FinagleBuildRevision extends Logging {

  def register(injector: Injector): Unit = {
    com.twitter.finagle.Init.finagleBuildRevision match {
      case "?" =>
        warn("Unable to resolve Finagle revision.")
      case revision =>
        debug(s"Resolved Finagle build revision: (rev=$revision)")
        injector.instance[StatsReceiver].scope("finagle").provideGauge("build/revision") {
          convertBuildRevision(revision).toFloat
        }
    }
  }

  /* Private */

  private[server] def convertBuildRevision(revision: String): Long = {
    try {
      revision.take(10).toU64Long
    } catch {
      case NonFatal(e) =>
        error(s"Unable to convert Finagle build revision to long: ${e.getMessage}")
        -1L
    }
  }
}

--- 
+++ 
@@ -3,7 +3,6 @@
 import com.twitter.finagle.stats.StatsReceiver
 import com.twitter.inject.{Injector, Logging}
 import scala.util.control.NonFatal
-import com.twitter.util.U64._
 
 object FinagleBuildRevision extends Logging {
 
@@ -23,7 +22,7 @@
 
   private[server] def convertBuildRevision(revision: String): Long = {
     try {
-      revision.take(10).toU64Long
+      java.lang.Long.parseUnsignedLong(revision.take(10), 16)
     } catch {
       case NonFatal(e) =>
         error(s"Unable to convert Finagle build revision to long: ${e.getMessage}")
source: Rewrite RichU64 APIs with JDK8's

# Problem / Solution

Util's `c.t.u.RichU64` tools predated JDK8, which has a built-in support to unsigned long values.
This change is removing the legacy API as we're on Java > 8.

JIRA Issues: CSL-6030

TBR=true

Differential Revision: https://phabricator.twitter.biz/D242277
