scala-stats icon indicating copy to clipboard operation
scala-stats copied to clipboard

Scala 2.8 branch and StatsMBean error

Open andrewmilkowski opened this issue 15 years ago • 0 comments
trafficstars

Hey there,

using 2.8 branch, compiling against latest incarnation of scala 2.8 (compiler and library from git master)

made following change (below) to get around "cast" error

Stats.getTimingStat returns a Map I believe, so maybe this would be appropriate cast, although AnyRef should suffice,

Thanks in advance, if you can quickly review this indeed is appropriate and without side-effects

best regards!

compile-scala: [scalac] Compiling 1 source file to /opt/local/src/svn/scala/scala-stats/git/target/classes [scalac] /opt/local/src/svn/scala/scala-stats/git/src/main/scala/com/twitter/stats/StatsMBean.scala:55: error: type mismatch; [scalac] found : Unit [scalac] required: AnyRef [scalac] Note: primitive types are not implicitly converted to AnyRef. [scalac] You can safely force boxing by casting x.asInstanceOf[AnyRef]. [scalac] case "timing" => [scalac] ^ [scalac] one error found

--- a/src/main/scala/com/twitter/stats/StatsMBean.scala +++ b/src/main/scala/com/twitter/stats/StatsMBean.scala @@ -51,10 +51,11 @@ class StatsMBean(resetTimings: Boolean, resetGauges: Boolean, resetCounters: Boo val segments = name.split("_", 2) segments(0) match { case "counter" =>

  •    Stats.getCounterStats(resetCounters)(segments(1)).asInstanceOf[java.lang.Long]
    
  •      Stats.getCounterStats(resetCounters)(segments(1)).asInstanceOf[java.lang.Long]
    
    case "timing" =>
  •    val prefix = segments(1).split("_", 2)
    
  •    val timing = Stats.getTimingStats(resetTimings)(prefix(1))
    
  •      val prefix = segments(1).split("_", 2)
    
  •      val timing = Stats.getTimingStats(resetTimings)(prefix(1))
    
  •      timing.asInstanceOf[AnyRef]
    
    case "gauge" => Stats.getGaugeStats(resetGauges)(segments(1)).asInstanceOf[java.lang.Double] }

andrewmilkowski avatar Jul 19 '10 15:07 andrewmilkowski