diff --git a/airframe-codec/src/main/scala/wvlet/airframe/codec/JDBCCodec.scala b/airframe-codec/src/main/scala/wvlet/airframe/codec/JDBCCodec.scala index 2c1a7446fb..48f8948048 100644 --- a/airframe-codec/src/main/scala/wvlet/airframe/codec/JDBCCodec.scala +++ b/airframe-codec/src/main/scala/wvlet/airframe/codec/JDBCCodec.scala @@ -58,7 +58,7 @@ object JDBCCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val size = u.unpackArrayHeader() for (i <- 0 until size) { u.unpackValue() diff --git a/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageCodec.scala b/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageCodec.scala index 8cab0ab280..bfdefaed51 100644 --- a/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageCodec.scala +++ b/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageCodec.scala @@ -22,8 +22,8 @@ import scala.reflect.runtime.{universe => ru} import scala.util.{Failure, Success, Try} trait MessageCodec[A] extends LogSupport { - def pack(p: MessagePacker, v: A) - def unpack(u: MessageUnpacker, v: MessageHolder) + def pack(p: MessagePacker, v: A): Unit + def unpack(u: MessageUnpacker, v: MessageHolder): Unit // TODO add specialized methods for primitive values // def unpackInt(u:MessageUnpacker) : Int @@ -51,11 +51,11 @@ trait MessageValueCodec[A] extends MessageCodec[A] { def pack(v: A): Value def unpack(v: Value): A - override def pack(p: MessagePacker, v: A) { + override def pack(p: MessagePacker, v: A): Unit = { p.packValue(pack(v)) } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val vl = u.unpackValue() Try(unpack(vl)) match { case Success(x) => diff --git a/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageHolder.scala b/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageHolder.scala index 65f9a7a7b5..106fb569a1 100644 --- a/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageHolder.scala +++ b/airframe-codec/src/main/scala/wvlet/airframe/codec/MessageHolder.scala @@ -33,51 +33,51 @@ class MessageHolder { def hasError: Boolean = err.isDefined def getError: Option[Throwable] = err - def setNull { + def setNull: Unit = { dataType = NIL value = None } - def setBoolean(v: Boolean) { + def setBoolean(v: Boolean): Unit = { setValue(BOOLEAN, v) b = v } - def setByte(v: Byte) { + def setByte(v: Byte): Unit = { setValue(INTEGER, v) l = v } - def setChar(v: Char) { + def setChar(v: Char): Unit = { setValue(INTEGER, v) l = v } - def setShort(v: Short) { + def setShort(v: Short): Unit = { setValue(INTEGER, v) l = v } - def setInt(v: Int) { + def setInt(v: Int): Unit = { setValue(INTEGER, v) l = v } - def setLong(v: Long) { + def setLong(v: Long): Unit = { setValue(INTEGER, v) l = v } - def setFloat(v: Float) { + def setFloat(v: Float): Unit = { setValue(FLOAT, v) d = v } - def setDouble(v: Double) { + def setDouble(v: Double): Unit = { setValue(FLOAT, v) d = v } - def setString(v: String) { + def setString(v: String): Unit = { setValue(STRING, v) s = v } - def setObject(v: Any) { + def setObject(v: Any): Unit = { if (v == null) { setNull } else { @@ -85,7 +85,7 @@ class MessageHolder { } } - protected def setValue(dataType: DataType, v: Any) { + protected def setValue(dataType: DataType, v: Any): Unit = { this.dataType = dataType if (v != null) { value = Some(v) @@ -152,12 +152,12 @@ class MessageHolder { def getLastValue: Any = value.getOrElse(null) - def setError[A](e: Throwable) { + def setError[A](e: Throwable): Unit = { setNull err = Option(e) } - def setIncompatibleFormatException[A](codec: MessageCodec[A], message: String) { + def setIncompatibleFormatException[A](codec: MessageCodec[A], message: String): Unit = { setError(new MessageCodecException(INVALID_DATA, codec, message)) } diff --git a/airframe-codec/src/main/scala/wvlet/airframe/codec/PrimitiveCodec.scala b/airframe-codec/src/main/scala/wvlet/airframe/codec/PrimitiveCodec.scala index 1ea58b624c..8e3259e82c 100644 --- a/airframe-codec/src/main/scala/wvlet/airframe/codec/PrimitiveCodec.scala +++ b/airframe-codec/src/main/scala/wvlet/airframe/codec/PrimitiveCodec.scala @@ -68,7 +68,7 @@ object PrimitiveCodec { } override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { - def read(body: => Byte) { + def read(body: => Byte): Unit = { try { v.setByte(body) } catch { @@ -111,7 +111,7 @@ object PrimitiveCodec { } override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { - def read(body: => Char) { + def read(body: => Char): Unit = { try { v.setChar(body) } catch { @@ -154,7 +154,7 @@ object PrimitiveCodec { } override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { - def read(body: => Short) { + def read(body: => Short): Unit = { try { v.setShort(body) } catch { @@ -195,8 +195,8 @@ object PrimitiveCodec { p.packInt(v) } - override def unpack(u: MessageUnpacker, v: MessageHolder) { - def read(body: => Int) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { + def read(body: => Int): Unit = { try { v.setInt(body) } catch { @@ -238,8 +238,8 @@ object PrimitiveCodec { p.packLong(v) } - override def unpack(u: MessageUnpacker, v: MessageHolder) { - def read(body: => Long) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { + def read(body: => Long): Unit = { try { v.setLong(body) } catch { @@ -284,8 +284,8 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { - def read(body: => String) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { + def read(body: => String): Unit = { try { val s = body v.setString(s) @@ -331,8 +331,8 @@ object PrimitiveCodec { p.packBoolean(v) } - override def unpack(u: MessageUnpacker, v: MessageHolder) { - def read(body: => Boolean) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { + def read(body: => Boolean): Unit = { try { val b = body v.setBoolean(b) @@ -374,8 +374,8 @@ object PrimitiveCodec { p.packFloat(v) } - override def unpack(u: MessageUnpacker, v: MessageHolder) { - def read(body: => Float) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { + def read(body: => Float): Unit = { try { v.setFloat(body) } catch { @@ -413,8 +413,8 @@ object PrimitiveCodec { p.packDouble(v) } - override def unpack(u: MessageUnpacker, v: MessageHolder) { - def read(body: => Double) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { + def read(body: => Double): Unit = { try { v.setDouble(body) } catch { @@ -453,7 +453,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Int] b.sizeHint(len) @@ -479,7 +479,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Short] b.sizeHint(len) @@ -510,7 +510,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Char] b.sizeHint(len) @@ -541,7 +541,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Long] b.sizeHint(len) @@ -567,7 +567,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Float] b.sizeHint(len) @@ -593,7 +593,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Double] b.sizeHint(len) @@ -618,7 +618,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[Boolean] b.sizeHint(len) @@ -655,7 +655,7 @@ object PrimitiveCodec { } } - override def unpack(u: MessageUnpacker, v: MessageHolder) { + override def unpack(u: MessageUnpacker, v: MessageHolder): Unit = { val len = u.unpackArrayHeader() val b = Array.newBuilder[String] b.sizeHint(len) diff --git a/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/ConnectionPool.scala b/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/ConnectionPool.scala index e2accbed1e..874f142611 100644 --- a/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/ConnectionPool.scala +++ b/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/ConnectionPool.scala @@ -51,7 +51,7 @@ trait ConnectionPool extends LogSupport { } } } - def executeUpdate(sql: String) { + def executeUpdate(sql: String): Unit = { // TODO Add update retry withConnection { conn => withResource(conn.createStatement()) { stmt => @@ -73,7 +73,7 @@ trait ConnectionPool extends LogSupport { } } - def updateWith(preparedStatement: String)(body: PreparedStatement => Unit) { + def updateWith(preparedStatement: String)(body: PreparedStatement => Unit): Unit = { withConnection { conn => withResource(conn.prepareStatement(preparedStatement)) { stmt => body(stmt) diff --git a/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/PostgreSQLConnectionPool.scala b/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/PostgreSQLConnectionPool.scala index 2d9bf16bca..5f7d8081b6 100644 --- a/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/PostgreSQLConnectionPool.scala +++ b/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/PostgreSQLConnectionPool.scala @@ -64,7 +64,7 @@ class PostgreSQLConnectionPool(val config: DbConfig, val pgConfig: PostgreSQLCon } } - def stop { + def stop: Unit = { info(s"Closing connection pool for ${config}") dataSource.close() } diff --git a/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/SQLiteConnectionPool.scala b/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/SQLiteConnectionPool.scala index dcd3069b51..e5fd0469cf 100644 --- a/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/SQLiteConnectionPool.scala +++ b/airframe-jdbc/src/main/scala/wvlet/airframe/jdbc/SQLiteConnectionPool.scala @@ -53,7 +53,7 @@ class SQLiteConnectionPool(val config: DbConfig) extends ConnectionPool with Gua } } - def stop { + def stop: Unit = { info(s"Closing connection pool for ${config}") conn.close() } diff --git a/airframe-log/jvm/src/test/scala/wvlet/log/AsyncHandlerTest.scala b/airframe-log/jvm/src/test/scala/wvlet/log/AsyncHandlerTest.scala index ca678c73f3..1f0a68f9cf 100644 --- a/airframe-log/jvm/src/test/scala/wvlet/log/AsyncHandlerTest.scala +++ b/airframe-log/jvm/src/test/scala/wvlet/log/AsyncHandlerTest.scala @@ -9,8 +9,6 @@ import wvlet.log.io.Timer */ class AsyncHandlerTest extends Spec with Timer { - import CompatParColls.Converters._ - "AsynHandler" should { "start background thread" in { val buf = new BufferedLogHandler(BareFormatter) @@ -54,22 +52,24 @@ class AsyncHandlerTest extends Spec with Timer { // sync sl.resetHandler(handler) - block("async") { - for (i <- (0 until N).par) { - al.info(s"hello world: ${i}") - } - } - - block("sync") { - for (i <- (0 until N).par) { - sl.info(s"hello world: ${i}") - } - } + // Temporarly removed to handle missing parallel collection issue of Scala 2.13.0-M4 + //import CompatParColls.Converters._ +// block("async") { +// for (i <- (0 until N).par) { +// al.info(s"hello world: ${i}") +// } +// } +// +// block("sync") { +// for (i <- (0 until N).par) { +// sl.info(s"hello world: ${i}") +// } +// } } } } val t = result(0) // heavy handler result - t("async").averageWithoutMinMax should be < t("sync").averageWithoutMinMax + //t("async").averageWithoutMinMax should be < t("sync").averageWithoutMinMax } } } diff --git a/airframe-log/shared/src/test/scala/wvlet/log/Spec.scala b/airframe-log/shared/src/test/scala/wvlet/log/Spec.scala index b8a4d8389d..8f9c3a856c 100644 --- a/airframe-log/shared/src/test/scala/wvlet/log/Spec.scala +++ b/airframe-log/shared/src/test/scala/wvlet/log/Spec.scala @@ -19,19 +19,19 @@ trait Spec extends WordSpec with Matchers with BeforeAndAfter with BeforeAndAfte super.afterAll() } - private[log] object CompatParColls { - val Converters = { - import Compat._ - - { - import scala.collection.parallel._ - - CollectionConverters - } - } - - object Compat { - object CollectionConverters - } - } +// private[log] object CompatParColls { +// val Converters = { +// import Compat._ +// +// { +// import scala.collection.parallel._ +// +// CollectionConverters +// } +// } +// +// object Compat { +// object CollectionConverters +// } +// } } diff --git a/airframe-opts/src/main/scala/wvlet/airframe/opts/OptionParser.scala b/airframe-opts/src/main/scala/wvlet/airframe/opts/OptionParser.scala index 65c5d9a327..ce8daed971 100755 --- a/airframe-opts/src/main/scala/wvlet/airframe/opts/OptionParser.scala +++ b/airframe-opts/src/main/scala/wvlet/airframe/opts/OptionParser.scala @@ -115,7 +115,7 @@ case class CLOption(path: Path, annot: option, override val param: Parameter) ex // validate prefixes val prefixes: Seq[String] = - for (p <- annot.prefix.split(",")) yield { + for (p <- annot.prefix.split(",").toSeq) yield { if (p.startsWith("--") || p.startsWith("-")) { p } else { @@ -241,7 +241,7 @@ object ClassOptionSchema extends LogSupport { } } - new ClassOptionSchema(surface, o.result, a.result().sortBy(x => x.argIndex)) + new ClassOptionSchema(surface, o.result.toSeq, a.result().toSeq.sortBy(x => x.argIndex)) } } diff --git a/airframe-spec/shared/src/main/scala/wvlet/airframe/AirframeSpec.scala b/airframe-spec/shared/src/main/scala/wvlet/airframe/AirframeSpec.scala index 05fe7fba45..edbde284fa 100644 --- a/airframe-spec/shared/src/main/scala/wvlet/airframe/AirframeSpec.scala +++ b/airframe-spec/shared/src/main/scala/wvlet/airframe/AirframeSpec.scala @@ -41,20 +41,22 @@ trait AirframeSpec Logger.stopScheduledLogLevelScan s } - - private[airframe] object CompatParColls { - val Converters = { - import Compat._ - - { - import scala.collection.parallel._ - - CollectionConverters - } - } - - object Compat { - object CollectionConverters - } - } +// Temporarily removed for Scala 2.13.0-M4, which doesn't have parallel collection yet. +// https://github.com/scala/scala-parallel-collections/issues/41 +// +// private[airframe] object CompatParColls { +// val Converters = { +// import Compat._ +// +// { +// import scala.collection.parallel._ +// +// CollectionConverters +// } +// } +// +// object Compat { +// object CollectionConverters +// } +// } } diff --git a/airframe-stream/src/main/scala/wvlet/airframe/stream/spi/SQLModel.scala b/airframe-stream/src/main/scala/wvlet/airframe/stream/spi/SQLModel.scala index a9e976104c..320a89791a 100644 --- a/airframe-stream/src/main/scala/wvlet/airframe/stream/spi/SQLModel.scala +++ b/airframe-stream/src/main/scala/wvlet/airframe/stream/spi/SQLModel.scala @@ -58,7 +58,7 @@ object SQLModel { object QName { def apply(s: String): QName = { // TODO handle quotation - QName(s.split("\\.")) + QName(s.split("\\.").toSeq) } } diff --git a/airframe-stream/src/main/scala/wvlet/airframe/stream/sql/parser/SQLInterpreter.scala b/airframe-stream/src/main/scala/wvlet/airframe/stream/sql/parser/SQLInterpreter.scala index 6908b2d116..3356484c58 100644 --- a/airframe-stream/src/main/scala/wvlet/airframe/stream/sql/parser/SQLInterpreter.scala +++ b/airframe-stream/src/main/scala/wvlet/airframe/stream/sql/parser/SQLInterpreter.scala @@ -68,6 +68,7 @@ class SQLInterpreter extends SqlBaseBaseVisitor[SQLModel] with LogSupport { .map { x => visitSortItem(x) } + .toSeq Sort(inputRelation, sortKeys) } @@ -131,9 +132,10 @@ class SQLInterpreter extends SqlBaseBaseVisitor[SQLModel] with LogSupport { } } - val selectItem: Seq[SelectItem] = ctx.selectItem().asScala.map { x => - visit(x).asInstanceOf[SelectItem] - } + val selectItem: Seq[SelectItem] = ctx + .selectItem().asScala.map { x => + visit(x).asInstanceOf[SelectItem] + }.toSeq val withAggregation = { if (ctx.groupBy() == null) { @@ -155,6 +157,7 @@ class SQLInterpreter extends SqlBaseBaseVisitor[SQLModel] with LogSupport { .map { expression(_) } + .toSeq val g = Aggregate(withFilter.get, selectItem, groupByKeys) @@ -173,7 +176,7 @@ class SQLInterpreter extends SqlBaseBaseVisitor[SQLModel] with LogSupport { private def fromClause(ctx: QuerySpecificationContext): Option[Relation] = { Option(ctx.relation()) .flatMap { r => - val relations = r.asScala + val relations = r.asScala.toSeq relations.size match { case 1 => relations.map(x => visit(x).asInstanceOf[Relation]).headOption @@ -204,7 +207,7 @@ class SQLInterpreter extends SqlBaseBaseVisitor[SQLModel] with LogSupport { } override def visitQualifiedName(ctx: QualifiedNameContext): QName = { - QName(ctx.identifier().asScala.map(_.getText)) + QName(ctx.identifier().asScala.map(_.getText).toSeq) } override def visitSelectAll(ctx: SelectAllContext): SelectItem = { diff --git a/airframe-surface/jvm/src/test/scala/wvlet/surface/SurfaceJVMTest.scala b/airframe-surface/jvm/src/test/scala/wvlet/surface/SurfaceJVMTest.scala index 60c4b15929..3ce3e84adf 100644 --- a/airframe-surface/jvm/src/test/scala/wvlet/surface/SurfaceJVMTest.scala +++ b/airframe-surface/jvm/src/test/scala/wvlet/surface/SurfaceJVMTest.scala @@ -16,7 +16,7 @@ package wvlet.surface import java.time.temporal.ChronoUnit import java.io.File -import scala.collection.parallel.ParSeq + import wvlet.surface object SurfaceJVMTest { @@ -28,7 +28,9 @@ class SurfaceJVMTest extends SurfaceSpec { "SurfaceJVM" should { "resolve ParSeq" in { - check(surface.of[ParSeq[Int]], "ParSeq[Int]") + pending + //import scala.collection.parallel.ParSeq + //check(surface.of[ParSeq[Int]], "ParSeq[Int]") } "resolve java util type" in {