Skip to content

Commit

Permalink
Upgrade to Scala 2.13.0-M5 (#232)
Browse files Browse the repository at this point in the history
* Upgrade to Scala 2.13.0-M5
* Upgrade ScalaTest and Scalacheck
* Update travis config for Scala 2.13.0-M5
* Scala 2.13.0-M5 confused java.util.logging.LogRecord and wvlet.log.LogRecord
* Fix scala/bug#11202 by explicitely specifying JMX annotation package path
* Use Scala test 3.0.6-SNAP4
* Add a workaround for Scala 2.13.0-M5 serialization bug: scala/bug#11192
* Exclude airframe-fluentd from Scala 2.13 build
* Exclude serilaization test for Scala 2.13.0-M5 instead of forking JVM
  • Loading branch information
xerial authored Oct 31, 2018
1 parent a580ddf commit c31a4da
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ matrix:
script:
- ./sbt ++$SCALA_VERSION "; coverage; ${PROJECT}/test; coverageReport"
- "./sbt coverageAggregate && bash <(curl -s https://codecov.io/bash)"
- env: SCALA_VERSION=2.13.0-M4 PROJECT=projectJVM2_13
- env: SCALA_VERSION=2.13.0-M5 PROJECT=projectJVM2_13
jdk: openjdk8
# Install fluentd
install:
- rvm use 2.2.5 --install --fuzzy
- gem install fluentd -v 1.2.6
services: postgresql
before_script: psql -c 'create database travis_ci_test;' -U postgres
script: ./sbt ++$SCALA_VERSION ${PROJECT}/test
# Exclude design serialization tests due to bug https://github.com/scala/bug/issues/11192
script: ./sbt ++$SCALA_VERSION "${PROJECT}/testOnly * -- -l serde"
- env: SCALA_VERSION=2.11.11 PROJECT=projectJVM
jdk: openjdk8
# Install fluentd
Expand Down
17 changes: 9 additions & 8 deletions airframe-jmx/src/main/scala/wvlet/airframe/jmx/JMXMBean.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ package wvlet.airframe.jmx

import java.lang.annotation.Annotation
import java.lang.reflect.Method
import javax.management._

import javax.management._
import wvlet.log.LogSupport
import wvlet.airframe.surface.reflect._
import wvlet.airframe.surface.{MethodSurface, Parameter, ParameterBase, Surface}

import scala.reflect.runtime.{universe => ru}
import wvlet.airframe.{jmx => aj}

/**
* Expose object information using DynamicMBean
Expand Down Expand Up @@ -76,7 +77,7 @@ object JMXMBean extends LogSupport {
// Find JMX description
val cl = obj.getClass

val description = cl.getAnnotation(classOf[JMX]) match {
val description = cl.getAnnotation(classOf[aj.JMX]) match {
case a if a != null => a.description()
case _ => ""
}
Expand Down Expand Up @@ -112,17 +113,17 @@ object JMXMBean extends LogSupport {

private def getDescription(h: ParameterBase): String = {
h match {
case p: Parameter => p.findAnnotationOf[JMX].map(_.description()).getOrElse("")
case m: MethodSurface => m.findAnnotationOf[JMX].map(_.description()).getOrElse("")
case p: Parameter => p.findAnnotationOf[aj.JMX].map(_.description()).getOrElse("")
case m: MethodSurface => m.findAnnotationOf[aj.JMX].map(_.description()).getOrElse("")
}
}

private def collectMBeanParameters(parent: Option[ParameterBase], tpe: ru.Type): Seq[MBeanParameter] = {
val surface = SurfaceFactory.ofType(tpe)
val methods = SurfaceFactory.methodsOfType(tpe)

val jmxParams: Seq[ParameterBase] = surface.params.filter(_.findAnnotationOf[JMX].isDefined) ++ methods.find(
_.findAnnotationOf[JMX].isDefined)
val jmxParams: Seq[ParameterBase] = surface.params.filter(_.findAnnotationOf[aj.JMX].isDefined) ++ methods.find(
_.findAnnotationOf[aj.JMX].isDefined)

jmxParams.flatMap { p =>
val paramName = parent.map(x => s"${x.name}.${p.name}").getOrElse(p.name)
Expand All @@ -149,15 +150,15 @@ object JMXMBean extends LogSupport {
private def isNestedMBean(p: ParameterBase): Boolean = {
import wvlet.airframe.surface.reflect._

val jmxParams = p.surface.params.find(x => x.findAnnotationOf[JMX].isDefined)
val jmxParams = p.surface.params.find(x => x.findAnnotationOf[aj.JMX].isDefined)
if (jmxParams.isDefined) {
true
} else {
SurfaceFactory.findTypeOf(p.surface) match {
case None => false
case Some(tpe) =>
val methods = SurfaceFactory.methodsOfType(tpe)
val jmxMethods = methods.find(m => m.findAnnotationOf[JMX].isDefined)
val jmxMethods = methods.find(m => m.findAnnotationOf[aj.JMX].isDefined)
jmxMethods.isDefined
}
}
Expand Down
6 changes: 2 additions & 4 deletions airframe-log/shared/src/main/scala/wvlet/log/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.logging._
import java.util.{Properties, logging => jl}

import wvlet.log.LogFormatter.SourceCodeLogFormatter

import scala.annotation.tailrec
import scala.language.experimental.macros
import scala.reflect.ClassTag
Expand Down Expand Up @@ -147,11 +145,11 @@ class Logger(private val name: String,
}

def log(level: LogLevel, source: LogSource, message: Any): Unit = {
log(LogRecord(level, source, formatLog(message)))
log(wvlet.log.LogRecord(level, source, formatLog(message)))
}

def logWithCause(level: LogLevel, source: LogSource, message: Any, cause: Throwable): Unit = {
log(LogRecord(level, source, formatLog(message), cause))
log(wvlet.log.LogRecord(level, source, formatLog(message), cause))
}

protected def isMultiLine(str: String) = str.contains("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package wvlet.airframe
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream}

import DesignTest._
import org.scalatest.Tag

object DesignSerializationTest {

Expand All @@ -42,13 +43,13 @@ class DesignSerializationTest extends AirframeSpec {
import DesignSerializationTest._

"Design" should {
"be serializable" taggedAs ("ser") in {
"be serializable" taggedAs (Serde) in {
val b = serialize(d1)
val d1s = deserialize(b)
d1s shouldBe (d1)
}

"serialize instance binding" taggedAs ("ser1") in {
"serialize instance binding" taggedAs (Serde) in {
val d = Design.blanc.bind[Message].toInstance(Hello("world"))
val b = serialize(d)
val ds = deserialize(b)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import DesignSerializationTest._
class ProviderSerializationTest extends AirframeSpec {

"Design" should {
"serialize design with provider" taggedAs ("ser") in {
"serialize design with provider" taggedAs (Serde) in {
val testBinderDesign =
providerDesign.bind[App].toProvider(provider5 _)

Expand All @@ -34,7 +34,7 @@ class ProviderSerializationTest extends AirframeSpec {
app shouldBe App(d1, d2, d3, d4, d5)
}

"serialize design with provider1" taggedAs ("ser-p1") in {
"serialize design with provider1" taggedAs (Serde) in {
val testBinderDesign =
providerDesign.bind[App].toProvider(provider1 _)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package wvlet.airframe

import org.scalatest.Tag
import wvlet.log.LogSupport

object SerializationTest extends LogSupport {
Expand All @@ -34,10 +35,12 @@ object SerializationTest extends LogSupport {

import DesignSerializationTest._

object Serde extends Tag("serde")

class SerializationTest extends AirframeSpec {

"Airframe" should {
"serialize provider" in {
"serialize provider" taggedAs (Serde) in {
import wvlet.airframe.SerializationTest._
val b = serialize(d)
val ds = deserialize(b)
Expand All @@ -48,7 +51,7 @@ class SerializationTest extends AirframeSpec {
s.build[App] shouldBe App(A1(1))
}

"serialize provider that involves toInstance of local var" in {
"serialize provider that involves toInstance of local var" taggedAs (Serde) in {
import ProviderSerializationExample._
import ProviderVal._

Expand Down
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import sbtcrossproject.{crossProject, CrossType}

val SCALA_2_13 = "2.13.0-M4"
val SCALA_2_12 = "2.12.7"
val SCALA_2_13 = "2.13.0-M5"
val SCALA_2_11 = "2.11.11"

val untilScala2_12 = SCALA_2_12 :: SCALA_2_11 :: Nil
val targetScalaVersions = SCALA_2_13 :: untilScala2_12

val SCALATEST_VERSION = "3.0.6-SNAP1"
val SCALATEST_VERSION = "3.0.6-SNAP4"
val SCALACHECK_VERSION = "1.14.0"
val SCALA_PARSER_COMBINATOR_VERSION = "1.1.1"
val SQLITE_JDBC_VERSION = "3.21.0.1"
Expand Down Expand Up @@ -134,14 +134,14 @@ lazy val jvmProjects: Seq[ProjectReference] = List(
msgpackJVM,
stream,
http,
jsonJVM,
fluentd
jsonJVM
)

// JVM projects that cannot be build in Scala 2.13
lazy val jvmProjects2_12: Seq[ProjectReference] = List(
finagle,
jsonBenchmark
jsonBenchmark,
fluentd
)

// Scala.js builds is only for Scala 2.12
Expand Down

0 comments on commit c31a4da

Please sign in to comment.