From 78902061bc1215d641236bcb65cccacf7482bb20 Mon Sep 17 00:00:00 2001 From: Nadav Wiener Date: Tue, 28 Jan 2020 21:31:07 +0200 Subject: [PATCH] = support scala 2.13 --- .travis.yml | 1 + build.sbt | 14 +++++++++----- .../src/main/scala/kamon/ReporterRegistry.scala | 4 ++-- kamon-core/src/main/scala/kamon/package.scala | 2 +- .../src/main/scala/kamon/util/DynamicAccess.scala | 2 +- kamon-core/src/main/scala/kamon/util/Filters.scala | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f85bcd02..e3bc06f60 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ script: - sbt +test scala: - 2.12.4 +dist: trusty jdk: - oraclejdk8 before_script: diff --git a/build.sbt b/build.sbt index 8c0d992e3..e3805c061 100644 --- a/build.sbt +++ b/build.sbt @@ -20,10 +20,10 @@ lazy val kamon = (project in file(".")) .aggregate(core, testkit, coreTests) val commonSettings = Seq( - scalaVersion := "2.12.8", + scalaVersion := "2.13.1", javacOptions += "-XDignore.symbol.file", resolvers += Resolver.mavenLocal, - crossScalaVersions := Seq("2.12.8", "2.11.12", "2.10.7"), + crossScalaVersions := Seq("2.13.1", "2.12.8", "2.11.12", "2.10.7"), concurrentRestrictions in Global += Tags.limit(Tags.Test, 1), scalacOptions ++= Seq( "-deprecation", @@ -36,6 +36,7 @@ val commonSettings = Seq( case Some((2,10)) => Seq("-Yno-generic-signatures", "-target:jvm-1.7") case Some((2,11)) => Seq("-Ybackend:GenBCode","-Ydelambdafy:method","-target:jvm-1.8") case Some((2,12)) => Seq("-opt:l:method") + case Some((2,13)) => Seq("-opt:l:method") case _ => Seq.empty }) ) @@ -48,7 +49,10 @@ lazy val core = (project in file("kamon-core")) "com.typesafe" % "config" % "1.3.1", "org.slf4j" % "slf4j-api" % "1.7.25", "org.hdrhistogram" % "HdrHistogram" % "2.1.11", - "com.lihaoyi" %% "fansi" % "0.2.4" + "com.lihaoyi" %% "fansi" % (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, 10 | 11 | 12)) => "0.2.4" + case Some((2, 13)) | _ => "0.2.8" + }) ) ) @@ -57,7 +61,7 @@ lazy val testkit = (project in file("kamon-testkit")) .settings(commonSettings: _*) .settings( libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.0.1" + "org.scalatest" %% "scalatest" % "3.0.8" ) ).dependsOn(core) @@ -71,7 +75,7 @@ lazy val coreTests = (project in file("kamon-core-tests")) .settings(commonSettings: _*) .settings( libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % "3.0.1" % "test", + "org.scalatest" %% "scalatest" % "3.0.8" % "test", "ch.qos.logback" % "logback-classic" % "1.2.2" % "test" ) ).dependsOn(testkit) diff --git a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala index ee70de4ae..ad9c14f97 100644 --- a/kamon-core/src/main/scala/kamon/ReporterRegistry.scala +++ b/kamon-core/src/main/scala/kamon/ReporterRegistry.scala @@ -381,7 +381,7 @@ object ReporterRegistry { Future { Try { - entry.reporter.reportSpans(spanBatch.asScala) + entry.reporter.reportSpans(spanBatch.asScala.toSeq) }.failed.foreach { error => logger.error(s"Reporter [${entry.name}] failed to report spans.", error) } @@ -396,7 +396,7 @@ object ReporterRegistry { optimisticMetricTickAlignment = config.getBoolean("kamon.metric.optimistic-tick-alignment"), traceTickInterval = config.getDuration("kamon.trace.tick-interval"), traceReporterQueueSize = config.getInt("kamon.trace.reporter-queue-size"), - configuredReporters = config.getStringList("kamon.reporters").asScala + configuredReporters = config.getStringList("kamon.reporters").asScala.toSeq ) private case class Configuration(metricTickInterval: Duration, optimisticMetricTickAlignment: Boolean, diff --git a/kamon-core/src/main/scala/kamon/package.scala b/kamon-core/src/main/scala/kamon/package.scala index d3b255008..d5507a0c1 100644 --- a/kamon-core/src/main/scala/kamon/package.scala +++ b/kamon-core/src/main/scala/kamon/package.scala @@ -67,7 +67,7 @@ package object kamon { implicit class AtomicGetOrElseUpdateOnTrieMap[K, V](val trieMap: TrieMap[K, V]) extends AnyVal { def atomicGetOrElseUpdate(key: K, op: ⇒ V): V = - atomicGetOrElseUpdate(key, op, { v: V ⇒ Unit }) + atomicGetOrElseUpdate(key, op, { v: V ⇒ () }) def atomicGetOrElseUpdate(key: K, op: ⇒ V, cleanup: V ⇒ Unit): V = trieMap.get(key) match { diff --git a/kamon-core/src/main/scala/kamon/util/DynamicAccess.scala b/kamon-core/src/main/scala/kamon/util/DynamicAccess.scala index 07e2e48e2..e1bc629f2 100644 --- a/kamon-core/src/main/scala/kamon/util/DynamicAccess.scala +++ b/kamon-core/src/main/scala/kamon/util/DynamicAccess.scala @@ -34,7 +34,7 @@ class DynamicAccess(val classLoader: ClassLoader) { Try[Class[_ <: T]]({ val c = Class.forName(fqcn, false, classLoader).asInstanceOf[Class[_ <: T]] val t = implicitly[ClassTag[T]].runtimeClass - if (t.isAssignableFrom(c)) c else throw new ClassCastException(t + " is not assignable from " + c) + if (t.isAssignableFrom(c)) c else throw new ClassCastException(s"$t is not assignable from $c") }) def createInstanceFor[T: ClassTag](clazz: Class[_], args: immutable.Seq[(Class[_], AnyRef)]): Try[T] = diff --git a/kamon-core/src/main/scala/kamon/util/Filters.scala b/kamon-core/src/main/scala/kamon/util/Filters.scala index a6c4de88b..24a271763 100644 --- a/kamon-core/src/main/scala/kamon/util/Filters.scala +++ b/kamon-core/src/main/scala/kamon/util/Filters.scala @@ -39,7 +39,7 @@ object Filters { val configKey = ConfigUtil.joinPath(name, key) if(filtersConfig.hasPath(configKey)) - filtersConfig.getStringList(configKey).asScala.map(readMatcher) + filtersConfig.getStringList(configKey).asScala.toSeq.map(readMatcher) else Seq.empty }