Skip to content

Commit

Permalink
fix most 2.13 compiler warnings (#1070)
Browse files Browse the repository at this point in the history
There is still one related to ordering doubles, but is not
easily fixable until the 2.12 build is dropped.
  • Loading branch information
brharrington authored Jul 11, 2019
1 parent 5ae2d2e commit f343962
Show file tree
Hide file tree
Showing 54 changed files with 80 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ActorService @Inject()(system: ActorSystem, config: Config, classFactory:
with StrictLogging {

override def startImpl(): Unit = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config.getConfigList("atlas.akka.actors").asScala.foreach { cfg =>
val name = cfg.getString("name")
val cls = Class.forName(cfg.getString("class"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ConfigApi(config: Config, implicit val actorRefFactory: ActorRefFactory) e
}

private def getPathValue(config: Config, p: String): Config = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
try config.getConfig(p)
catch {
case e: ConfigException.WrongType =>
Expand All @@ -107,7 +107,7 @@ class ConfigApi(config: Config, implicit val actorRefFactory: ActorRefFactory) e
}

private def formatProperties(config: Config): HttpResponse = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val props = new Properties
config.entrySet.asScala.foreach { t =>
props.setProperty(t.getKey, s"${t.getValue.unwrapped}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class HealthcheckApi(serviceManagerProvider: Provider[ServiceManager])
private def serviceManager: ServiceManager = serviceManagerProvider.get

private def summary: String = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val states = serviceManager.services().asScala.map(s => s.name -> s.isHealthy).toMap
Json.encode(states)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,17 @@ class RequestHandler(config: Config, classFactory: ClassFactory) extends StrictL
}

private def endpoints: List[String] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config.getStringList("atlas.akka.api-endpoints").asScala.toList.distinct
}

private def corsHostPatterns: List[String] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config.getStringList("atlas.akka.cors-host-patterns").asScala.toList.distinct
}

private def diagnosticHeaders: List[HttpHeader] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config
.getConfigList("atlas.akka.diagnostic-headers")
.asScala
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class StaticPages(config: Config) extends WebApi {
getFromResourceDirectory("www")
}

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val singlePagePrefixes = config.getConfigList("atlas.akka.static.single-page-prefixes")
singlePagePrefixes.asScala.foldLeft(staticFiles) { (acc, cfg) =>
val prefix = cfg.getString("prefix")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ConfigApiSuite extends FunSuite with ScalatestRouteTest {
}

test("/config/os.arch") {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
Get("/api/v2/config/os.arch") ~> endpoint.routes ~> check {
val config = ConfigFactory.parseString(responseAs[String])
val v = sysConfig.getString("os.arch")
Expand All @@ -81,7 +81,7 @@ class ConfigApiSuite extends FunSuite with ScalatestRouteTest {

test("/config format properties") {
Get("/api/v2/config?format=properties") ~> endpoint.routes ~> check {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val props = new Properties
props.load(new StringReader(responseAs[String]))
val config = ConfigFactory.parseProperties(props)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StreamOpsSuite extends FunSuite {
private implicit val materializer = ActorMaterializer()

private def checkOfferedCounts(registry: Registry, expected: Map[String, Double]): Unit = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
registry
.stream()
.iterator()
Expand Down Expand Up @@ -146,7 +146,7 @@ class StreamOpsSuite extends FunSuite {
}

private def checkCounts(registry: Registry, name: String, expected: Map[String, Double]): Unit = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
registry
.stream()
.iterator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import com.netflix.atlas.core.util.UnitPrefix
class DefaultGraphEngine extends PngGraphEngine {

private val renderingHints = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val config = ConfigManager.current.getConfig("atlas.chart.rendering-hints")
config.entrySet.asScala.toList.map { entry =>
val k = getField(entry.getKey).asInstanceOf[RenderingHints.Key]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private[chart] object JsonCodec {
private def toGraphDef(node: JsonNode): GraphDef = {

// format: off
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
GraphDef(
Nil,
startTime = Instant.ofEpochMilli(node.get("startTime").asLong()),
Expand Down Expand Up @@ -395,7 +395,7 @@ private[chart] object JsonCodec {
}

private def toTimeSeries(gdef: GraphDef, node: JsonNode): TimeSeries = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val tags = node.get("tags").fields.asScala.map(e => e.getKey -> e.getValue.asText()).toMap
val values = node.get("data").get("values").elements.asScala.map(_.asDouble()).toArray
val seq = new ArrayTimeSeq(DsType.Gauge, gdef.startTime.toEpochMilli, gdef.step, values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ final class SmallHashMap[K <: Any, V <: Any] private (val data: Array[Any], data

def get(key: K): Option[V] = Option(getOrNull(key))

override def foreach[U](f: ((K, V)) => U) {
override def foreach[U](f: ((K, V)) => U): Unit = {
var i = 0
while (i < data.length) {
if (data(i) != null) f(data(i).asInstanceOf[K] -> data(i + 1).asInstanceOf[V])
Expand Down Expand Up @@ -426,7 +426,7 @@ final class SmallHashMap[K <: Any, V <: Any] private (val data: Array[Any], data
* the entry set is needed.
*/
override def entrySet(): java.util.Set[java.util.Map.Entry[K, V]] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
self.asJava.entrySet()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ final class SmallHashMap[K <: Any, V <: Any] private (val data: Array[Any], data
* the entry set is needed.
*/
override def entrySet(): java.util.Set[java.util.Map.Entry[K, V]] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
self.asJava.entrySet()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class MemoryDatabase(registry: Registry, config: Config) extends Database {
case _: DataExpr.All => tags
case _ =>
val resultKeys = Query.exactKeys(expr.query) ++ expr.finalGrouping
tags.filterKeys(resultKeys.contains).toMap
tags.filter(t => resultKeys.contains(t._1))
}
TimeSeriesBuffer(resultTags, cfStep, bufStart, bufEnd)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class BatchUpdateTagIndex[T <: TaggedItem: ClassTag](
def rebuildIndex(): Unit = {
val timerId = rebuildTimer.start()
try {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

// Drain the update queue and create map of items for deduping, we put new items in the
// map first so that an older item, if present, will be preferred
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import com.typesafe.config.Config
*/
class CustomVocabulary(config: Config) extends Vocabulary {
import CustomVocabulary._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

val name: String = "custom"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ object DataExpr {
// 32 is typically big enough to prevent a resize with a single key
val builder = new StringBuilder(32 * keys.size)
builder.append('(')
keys.foreach { k =>
val it = keys.iterator
while (it.hasNext) {
val k = it.next()
val v = tags.get(k)
if (v.isEmpty) return null
builder.append(k).append('=').append(v.get).append(' ')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ object StatefulExpr {
// Update the stateful buffers for expressions that do not have an explicit value for
// this interval. For streaming contexts only data that is reported for that interval
// will be present, but the state needs to be moved for all entries.
val noDataIds = state.keySet -- rs.data.map(_.id)
val noDataIds = state.keySet.diff(rs.data.map(_.id).toSet)
noDataIds.foreach { id =>
val algo = OnlineAlgorithm(state(id))
algo.next(Double.NaN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ case class ReservedKeyRule(prefix: String, allowedKeys: Set[String]) extends Tag
object ReservedKeyRule {

def apply(config: Config): ReservedKeyRule = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

val prefix = config.getString("prefix")
val allowedKeys =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ trait Rule {
object Rule {

def load(ruleConfigs: java.util.List[_ <: Config]): List[Rule] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
load(ruleConfigs.asScala.toList)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ case class ValidCharactersRule(defaultSet: AsciiSet, overrides: Map[String, Asci
object ValidCharactersRule {

def apply(config: Config): ValidCharactersRule = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

def loadOverrides: Map[String, AsciiSet] = {
val entries = config.getConfigList("overrides").asScala.map { cfg =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ object DataSet {
val sps = app + ("name" -> ("sps_" + j))

val idealF = wave(conf._2, conf._3, Duration.ofDays(1))
idealF.withTags(sps + ("type" -> "ideal", "type2" -> "IDEAL"))
idealF.withTags(sps ++ Seq("type" -> "ideal", "type2" -> "IDEAL"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BlockSuite extends FunSuite {
Block.compress(block)
}

def checkValues(b: Block, values: List[Double]) {
def checkValues(b: Block, values: List[Double]): Unit = {
values.zipWithIndex.foreach { v =>
val msg = "b(%d) => %f != %f".format(v._2, b.get(v._2), v._1)
val res = java.lang.Double.compare(v._1, b.get(v._2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PercentilesSuite extends FunSuite {
}

private val inputSpectatorTimer = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val r = new DefaultRegistry()
val t = PercentileTimer.get(r, r.createId("test"))
(0 until 100).foreach { i =>
Expand All @@ -102,7 +102,7 @@ class PercentilesSuite extends FunSuite {
}

private val inputSpectatorDistSummary = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val r = new DefaultRegistry()
val t = PercentileDistributionSummary.get(r, r.createId("test"))
(0 until 100).foreach { i =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class SmallHashMapSuite extends FunSuite {
assert(expected === actual)
}

private def testNumCollisions(m: SmallHashMap[String, String]) {
private def testNumCollisions(m: SmallHashMap[String, String]): Unit = {

//printf("%d: %d collisions, %.2f probes%n", m.size, m.numCollisions, m.numProbesPerKey)
assert(m.numProbesPerKey < m.size / 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ case class DefaultSettings(root: Config, config: Config) {

/** Available engines for rendering a chart. */
val engines: Map[String, GraphEngine] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config
.getStringList("engines")
.asScala
Expand All @@ -92,7 +92,7 @@ case class DefaultSettings(root: Config, config: Config) {
/** Content types for the various rendering options. */
val contentTypes: Map[String, ContentType] = engines.map {
case (k, e) =>
k -> ContentType.parse(e.contentType).right.get
k -> ContentType.parse(e.contentType).toOption.get
}

/** Vocabulary to use in the interpreter when evaluating a graph expression. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private[stream] class EurekaGroupsLookup(context: StreamContext, frequency: Fini
private var continue = new AtomicBoolean(true)

override def onPush(): Unit = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

// If there is an existing source polling Eureka, then tell it to stop. Create a
// new instance of the flag for the next source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import com.typesafe.config.Config
import org.reactivestreams.Processor
import org.reactivestreams.Publisher

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.concurrent.Await
import scala.concurrent.duration._

Expand Down Expand Up @@ -265,7 +265,7 @@ private[stream] abstract class EvaluatorImpl(
exprs.filter(_.query.matches(tags)).map { expr =>
// Restrict the tags to the common set for all matches to the data expression
val keys = Query.exactKeys(expr.query) ++ expr.finalGrouping
val exprTags = tags.filterKeys(keys.contains).toMap
val exprTags = tags.filter(t => keys.contains(t._1))

// Need to do the init for count aggregate
val v = d.getValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private[stream] class ExprInterpreter(config: Config) {
}

def dataExprMap(ds: DataSources): Map[DataExpr, List[DataSource]] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
ds.getSources.asScala.toList
.flatMap { s =>
val exprs = eval(Uri(s.getUri)).flatMap(_.expr.dataExprs).distinct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private[stream] class FinalExprEval(interpreter: ExprInterpreter)

// Updates the recipients list
private def handleDataSources(ds: DataSources): Unit = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val sources = ds.getSources.asScala.toList
step = ds.stepSize()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private[stream] class StreamContext(
private val config = rootConfig.getConfig("atlas.eval.stream")

private val backends = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config.getConfigList("backends").asScala.toList.map { cfg =>
EurekaBackend(
cfg.getString("host"),
Expand All @@ -72,7 +72,7 @@ private[stream] class StreamContext(
}

private val ignoredTagKeys = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
config.getStringList("ignored-tag-keys").asScala.toSet
}

Expand Down Expand Up @@ -123,7 +123,7 @@ private[stream] class StreamContext(
* message will be written to the `dsLogger` for any failures.
*/
def validate(input: DataSources): DataSources = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val valid = new java.util.HashSet[DataSource]()
input.getSources.asScala.foreach { ds =>
validateDataSource(ds) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private[stream] class SubscriptionManager(context: StreamContext)

private def handleDataSources(dataSources: DataSources): Unit = {
// Log changes to the data sources for easier debugging
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
logSources("added", dataSources.addedSources(sources).asScala.toList)
logSources("removed", dataSources.removedSources(sources).asScala.toList)
sources = dataSources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private[stream] class TimeGrouped(
* so it can be used for a new time window.
*/
private def flush(i: Int): Unit = {
val vs = buf(i).mapValues(_.datapoints).toMap
val vs = buf(i).map(t => t._1 -> t._2.datapoints).toMap
val t = timestamps(i)
if (t > 0) push(out, TimeGroup(t, step, vs)) else pull(in)
cutoffTime = t
Expand Down Expand Up @@ -149,7 +149,7 @@ private[stream] class TimeGrouped(

override def onUpstreamFinish(): Unit = {
val groups = buf.indices.map { i =>
val vs = buf(i).mapValues(_.datapoints).toMap
val vs = buf(i).map(t => t._1 -> t._2.datapoints).toMap
TimeGroup(timestamps(i), step, vs)
}.toList
pending = groups.filter(_.timestamp > 0).sortWith(_.timestamp < _.timestamp)
Expand Down
Loading

0 comments on commit f343962

Please sign in to comment.