Skip to content

Commit

Permalink
Add :Unit since procedure syntax is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Jul 18, 2018
1 parent 4d09069 commit 98280a7
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,59 +33,59 @@ 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 {
setValue(ANY, v)
}
}

protected def setValue(dataType: DataType, v: Any) {
protected def setValue(dataType: DataType, v: Any): Unit = {
this.dataType = dataType
if (v != null) {
value = Some(v)
Expand Down Expand Up @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
28 changes: 14 additions & 14 deletions airframe-log/jvm/src/test/scala/wvlet/log/AsyncHandlerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
}
}
Expand Down
Loading

0 comments on commit 98280a7

Please sign in to comment.