diff --git a/src/main/scala/com/redis/PubSub.scala b/src/main/scala/com/redis/PubSub.scala index 67a6b3b0..f13b8506 100644 --- a/src/main/scala/com/redis/PubSub.scala +++ b/src/main/scala/com/redis/PubSub.scala @@ -2,8 +2,8 @@ package com.redis object Util { object Break extends RuntimeException - def break { throw Break } - def whileTrue(block: => Unit) { + def break: Unit = { throw Break } + def whileTrue(block: => Unit): Unit = { while (true) try { block @@ -23,12 +23,12 @@ trait PubSub extends PubOperations { self: Redis => class Consumer(fn: PubSubMessage => Any) extends Runnable { - def start () { + def start (): Unit = { val myThread = new Thread(this) ; myThread.start() ; } - override def run() { + override def run(): Unit = { try { whileTrue { asList match { @@ -62,7 +62,7 @@ trait PubSub extends PubOperations { self: Redis => } } - def pSubscribe(channel: String, channels: String*)(fn: PubSubMessage => Any) { + def pSubscribe(channel: String, channels: String*)(fn: PubSubMessage => Any): Unit = { if (pubSub) { // already pubsub ing pSubscribeRaw(channel, channels: _*) return @@ -72,7 +72,7 @@ trait PubSub extends PubOperations { self: Redis => new Consumer(fn).start() } - def pSubscribeRaw(channel: String, channels: String*) { + def pSubscribeRaw(channel: String, channels: String*): Unit = { send("PSUBSCRIBE", channel :: channels.toList)(()) } @@ -83,7 +83,7 @@ trait PubSub extends PubOperations { self: Redis => def pUnsubscribe(channel: String, channels: String*): Unit = { send("PUNSUBSCRIBE", channel :: channels.toList)(()) } - def subscribe(channel: String, channels: String*)(fn: PubSubMessage => Any) { + def subscribe(channel: String, channels: String*)(fn: PubSubMessage => Any): Unit = { if (pubSub) { // already pubsub ing subscribeRaw(channel, channels: _*) } else { @@ -93,7 +93,7 @@ trait PubSub extends PubOperations { self: Redis => } } - def subscribeRaw(channel: String, channels: String*) { + def subscribeRaw(channel: String, channels: String*): Unit = { send("SUBSCRIBE", channel :: channels.toList)(()) } diff --git a/src/main/scala/com/redis/RedisClient.scala b/src/main/scala/com/redis/RedisClient.scala index 0cb4f82b..1a0fa07c 100644 --- a/src/main/scala/com/redis/RedisClient.scala +++ b/src/main/scala/com/redis/RedisClient.scala @@ -88,12 +88,12 @@ trait RedisCommand extends Redis with Operations } } - private def selectDatabase() { + private def selectDatabase(): Unit = { if (database != 0) select(database) } - private def authenticate() { + private def authenticate(): Unit = { secret.foreach(auth _) } diff --git a/src/main/scala/com/redis/cluster/HashRing.scala b/src/main/scala/com/redis/cluster/HashRing.scala index de617973..36ca7e4b 100644 --- a/src/main/scala/com/redis/cluster/HashRing.scala +++ b/src/main/scala/com/redis/cluster/HashRing.scala @@ -41,7 +41,7 @@ case class HashRing[T](nodes: List[T], replicas: Int) { /* * Removes node from the ring */ - def removeNode(node: T) { + def removeNode(node: T): Unit = { cluster -= node (1 to replicas).foreach {replica => ring -= nodeHashFor(node, replica) diff --git a/src/main/scala/com/redis/cluster/RedisCluster.scala b/src/main/scala/com/redis/cluster/RedisCluster.scala index e27a04e6..6d9233f2 100644 --- a/src/main/scala/com/redis/cluster/RedisCluster.scala +++ b/src/main/scala/com/redis/cluster/RedisCluster.scala @@ -111,7 +111,7 @@ abstract class RedisCluster(hosts: ClusterNode*) extends RedisCommand { } //remove a server - def removeServer(nodename: String){ + def removeServer(nodename: String): Unit ={ hr.cluster.find(_.node.nodename.equals(nodename)) match { case Some(pool) => { hr removeNode(pool) diff --git a/src/main/scala/com/redis/cluster/RedisShards.scala b/src/main/scala/com/redis/cluster/RedisShards.scala index 0360de03..c7c9c8fa 100644 --- a/src/main/scala/com/redis/cluster/RedisShards.scala +++ b/src/main/scala/com/redis/cluster/RedisShards.scala @@ -49,7 +49,7 @@ abstract class RedisShards(val hosts: List[ClusterNode]) extends RedisCommand { } //remove a server - def removeServer(nodename: String){ + def removeServer(nodename: String): Unit ={ if (clients.contains(nodename)) { val pool = clients(nodename) pool.close diff --git a/src/test/scala/com/redis/BlockingDequeSpec.scala b/src/test/scala/com/redis/BlockingDequeSpec.scala index 30b3f45a..f6fec634 100644 --- a/src/test/scala/com/redis/BlockingDequeSpec.scala +++ b/src/test/scala/com/redis/BlockingDequeSpec.scala @@ -21,12 +21,12 @@ class BlockingDequeSpec extends FunSpec val r2 = new RedisDequeClient("localhost", 6379).getDeque("btd", blocking = true, timeoutInSecs = 30) class Foo extends Runnable { - def start () { + def start (): Unit = { val myThread = new Thread(this) ; myThread.start() ; } - def run { + def run: Unit = { val v = r1.poll v.get should equal("foo") r1.clear @@ -47,12 +47,12 @@ class BlockingDequeSpec extends FunSpec val r2 = new RedisDequeClient("localhost", 6379).getDeque("btd", blocking = true, timeoutInSecs = 30) class Foo extends Runnable { - def start () { + def start (): Unit = { val myThread = new Thread(this) ; myThread.start() ; } - def run { + def run: Unit = { val v = r1.pollLast v.get should equal("foo") r1.clear diff --git a/src/test/scala/com/redis/ListOperationsSpec.scala b/src/test/scala/com/redis/ListOperationsSpec.scala index dd60442a..8bf25f0c 100644 --- a/src/test/scala/com/redis/ListOperationsSpec.scala +++ b/src/test/scala/com/redis/ListOperationsSpec.scala @@ -354,12 +354,12 @@ class ListOperationsSpec extends FunSpec it("should pop blockingly") { val r1 = new RedisClient("localhost", 6379) class Foo extends Runnable { - def start () { + def start (): Unit = { val myThread = new Thread(this) ; myThread.start() ; } - def run { + def run: Unit = { r.brpoplpush("l1", "l2", 3) should equal(Some("a")) r1.disconnect r.lpop("l2") should equal(Some("a")) @@ -383,12 +383,12 @@ class ListOperationsSpec extends FunSpec it ("should pop in a blocking mode") { val r1 = new RedisClient("localhost", 6379) class Foo extends Runnable { - def start () { + def start (): Unit = { val myThread = new Thread(this) ; myThread.start() ; } - def run { + def run: Unit = { r.blpop(3, "l1", "l2") should equal(Some("l1", "a")) r1.disconnect } diff --git a/src/test/scala/com/redis/WatchSpec.scala b/src/test/scala/com/redis/WatchSpec.scala index 91411f8a..787a96cb 100644 --- a/src/test/scala/com/redis/WatchSpec.scala +++ b/src/test/scala/com/redis/WatchSpec.scala @@ -32,7 +32,7 @@ class WatchSpec extends FunSpec it("should fail a transaction if modified from another client") { implicit val clients = new RedisClientPool("localhost", 6379) class P1 extends Runnable { - def run() { + def run(): Unit = { clients.withClient { client => client.watch("key") client.pipeline { p => @@ -45,7 +45,7 @@ class WatchSpec extends FunSpec } } class P2 extends Runnable { - def run() { + def run(): Unit = { clients.withClient { client => Thread.sleep(10) client.set("key", "anshin")