Skip to content

Commit

Permalink
fix warnings in contrib, docs, osgi, persistence and slf4j
Browse files Browse the repository at this point in the history
  • Loading branch information
rkuhn committed Feb 6, 2015
1 parent 82b8238 commit a029a90
Show file tree
Hide file tree
Showing 17 changed files with 116 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ object DistributedPubSubMediator {

def business: Receive

def receive = business orElse defaultReceive
def receive = business.orElse[Any, Unit](defaultReceive)

def remove(ref: ActorRef): Unit = {
if (subscribers.contains(ref))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ trait ReceivePipeline extends Actor {
val around = aroundCache match {
case Some((`receive`, cached)) cached
case _
val zipped = pipeline.foldRight(receive)((outer, inner) outer(inner) orElse inner)
val zipped = pipeline.foldRight[Receive](receive)((outer, inner) outer(inner).orElse[Any, Unit](inner))
aroundCache = Some((receive, zipped))
zipped
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,60 @@ package akka.contrib.pattern

import akka.testkit.{ ImplicitSender, AkkaSpec }
import akka.actor.{ Actor, Props }
import scala.concurrent.duration._

class ReplierActor extends Actor with ReceivePipeline {
def receive: Actor.Receive = becomeAndReply
def becomeAndReply: Actor.Receive = {
case "become" context.become(justReply)
case m sender ! m
object ReceivePipelineSpec {

class ReplierActor extends Actor with ReceivePipeline {
def receive: Actor.Receive = becomeAndReply
def becomeAndReply: Actor.Receive = {
case "become" context.become(justReply)
case m sender ! m
}
def justReply: Actor.Receive = {
case m sender ! m
}
}
def justReply: Actor.Receive = {
case m sender ! m

case class IntList(l: List[Int]) {
override def toString: String = s"IntList(${l.mkString(", ")})"
}
}

trait ListBuilderInterceptor {
this: ReceivePipeline
trait ListBuilderInterceptor {
this: ReceivePipeline

pipelineOuter(inner
{
case n: Int inner((n until n + 3).toList)
})
}
pipelineOuter(inner
{
case n: Int inner(IntList((n until n + 3).toList))
})
}

trait AdderInterceptor {
this: ReceivePipeline
trait AdderInterceptor {
this: ReceivePipeline

pipelineInner(inner
{
case n: Int inner(n + 10)
case l: List[Int] inner(l.map(_ + 10))
case "explicitly ignored"
})
}
pipelineInner(inner
{
case n: Int inner(n + 10)
case IntList(l) inner(IntList(l.map(_ + 10)))
case "explicitly ignored"
})
}

trait ToStringInterceptor {
this: ReceivePipeline
trait ToStringInterceptor {
this: ReceivePipeline

pipelineInner(inner
{
case i: Int inner(i.toString)
case IntList(l) inner(l.toString)
case other: Iterable[_] inner(other.toString)
})
}

pipelineInner(inner
{
case i: Int inner(i.toString)
case l: Iterable[_] inner(l.toString())
})
}

class ReceivePipelineSpec extends AkkaSpec with ImplicitSender {
import ReceivePipelineSpec._

"A ReceivePipeline" must {

Expand Down Expand Up @@ -82,7 +93,8 @@ class ReceivePipelineSpec extends AkkaSpec with ImplicitSender {
val replier = system.actorOf(Props(
new ReplierActor with ListBuilderInterceptor with AdderInterceptor with ToStringInterceptor))
replier ! "explicitly ignored"
expectNoMsg()
replier ! 8L // unhandled by all interceptors but still replied
expectMsg(8L)
}

"support changing behavior without losing the interceptions" in {
Expand All @@ -101,9 +113,9 @@ class ReceivePipelineSpec extends AkkaSpec with ImplicitSender {
val innerOuterReplier = system.actorOf(Props(
new ReplierActor with AdderInterceptor with ListBuilderInterceptor))
outerInnerReplier ! 4
expectMsg(List(14, 15, 16))
expectMsg(IntList(List(14, 15, 16)))
innerOuterReplier ! 6
expectMsg(List(16, 17, 18))
expectMsg(IntList(List(16, 17, 18)))
}

}
Expand Down Expand Up @@ -231,7 +243,7 @@ object MixinSample extends App {
// The Dude says 'Yeah, well, you know, that's just, like, your opinion, man.'
//#mixin-actor

system.shutdown()
system.terminate()
}

object UnhandledSample extends App {
Expand Down
3 changes: 3 additions & 0 deletions akka-docs/rst/additional/code/docs/faq/Faq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class MyActor extends Actor {
case BarMessage(bar) => sender() ! BazMessage("Got " + bar)
// warning here:
// "match may not be exhaustive. It would fail on the following input: FooMessage(_)"
//#exhaustiveness-check
case FooMessage(_) => // avoid the warning in our build logs
//#exhaustiveness-check
}
}
}
Expand Down
1 change: 1 addition & 0 deletions akka-docs/rst/java/code/docs/future/FutureDocTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ public String apply(scala.Tuple2<String, String> zipped) {
}

@Test(expected = IllegalStateException.class)
@SuppressWarnings("unchecked")
public void useAfter() throws Exception {
//#after
final ExecutionContext ec = system.dispatcher();
Expand Down
4 changes: 2 additions & 2 deletions akka-docs/rst/scala/code/docs/actor/ActorDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ActorWithMessagesWrapper {
import MyActor._
def receive = {
case Greeting(greeter) => log.info(s"I was greeted by $greeter.")
case Goodbye => log.info("Someone said goodbye to me.")
case Goodbye => log.info("Someone said goodbye to me.")
}
}
//#messages-in-companion
Expand Down Expand Up @@ -229,7 +229,7 @@ class Consumer extends Actor with ActorLogging with ConsumerBehavior {
class ProducerConsumer extends Actor with ActorLogging
with ProducerBehavior with ConsumerBehavior {

def receive = producerBehavior orElse consumerBehavior
def receive = producerBehavior.orElse[Any, Unit](consumerBehavior)
}

// protocol
Expand Down
23 changes: 16 additions & 7 deletions akka-docs/rst/scala/code/docs/actor/FSMDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ import akka.util.ByteString
import akka.actor.Props
import scala.collection.immutable

class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {

//#fsm-code-elided
//#simple-imports
import akka.actor.{ ActorRef, FSM }
import scala.concurrent.duration._
//#simple-imports
object FSMDocSpec {
// messages and data types
//#test-code
import akka.actor.ActorRef
//#simple-events
// received events
final case class SetTarget(ref: ActorRef)
Expand All @@ -38,6 +35,17 @@ class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
case object Uninitialized extends Data
final case class Todo(target: ActorRef, queue: immutable.Seq[Any]) extends Data
//#simple-state
//#test-code
}

class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
import FSMDocSpec._

//#fsm-code-elided
//#simple-imports
import akka.actor.{ ActorRef, FSM }
import scala.concurrent.duration._
//#simple-imports
//#simple-fsm
class Buncher extends FSM[State, Data] {

Expand All @@ -56,6 +64,7 @@ class FSMDocSpec extends MyFavoriteTestFrameWorkPlusAkkaTestKit {
case Active -> Idle =>
stateData match {
case Todo(ref, queue) => ref ! Batch(queue)
case _ => // nothing to do
}
}
//#transition-elided
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class Worker extends Actor with ActorLogging {
//#messages
object CounterService {
final case class Increment(n: Int)
case object GetCurrentCount
sealed abstract class GetCurrentCount
case object GetCurrentCount extends GetCurrentCount
final case class CurrentCount(key: String, count: Long)
class ServiceUnavailable(msg: String) extends RuntimeException(msg)

Expand Down Expand Up @@ -176,9 +177,9 @@ class CounterService extends Actor {
for ((replyTo, msg) <- backlog) c.tell(msg, sender = replyTo)
backlog = IndexedSeq.empty

case msg @ Increment(n) => forwardOrPlaceInBacklog(msg)
case msg: Increment => forwardOrPlaceInBacklog(msg)

case msg @ GetCurrentCount => forwardOrPlaceInBacklog(msg)
case msg: GetCurrentCount => forwardOrPlaceInBacklog(msg)

case Terminated(actorRef) if Some(actorRef) == storage =>
// After 3 restarts the storage child is stopped.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class FaultHandlingDocSpec extends TestKit(ActorSystem("FaultHandlingDocSpec", t
}

"A supervisor" must "apply the chosen strategy for its child" in {
//#testkit
//#testkit

//#create
val supervisor = system.actorOf(Props[Supervisor], "supervisor")
Expand Down
4 changes: 2 additions & 2 deletions akka-docs/rst/scala/code/docs/actor/TypedActorDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class TypedActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {
//#typed-actor-call-strict
//#typed-actor-calls

Await.result(fSquare, 3 seconds) should be(100)
Await.result(fSquare, 3.seconds) should be(100)

oSquare should be(Some(100))

Expand Down Expand Up @@ -193,7 +193,7 @@ class TypedActorDocSpec extends AkkaSpec(Map("akka.loglevel" -> "INFO")) {

TypedActor(system).poisonPill(awesomeFooBar)
//#typed-actor-supercharge-usage
Await.result(f, 3 seconds) should be("YES")
Await.result(f, 3.seconds) should be("YES")
}

"typed router pattern" in {
Expand Down
7 changes: 4 additions & 3 deletions akka-docs/rst/scala/code/docs/io/EchoServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@ class EchoManager(handlerClass: Class[_]) extends Actor with ActorLogging {

}

//#echo-handler
object EchoHandler {
final case class Ack(offset: Int) extends Tcp.Event

def props(connection: ActorRef, remote: InetSocketAddress): Props =
Props(classOf[EchoHandler], connection, remote)
}

//#echo-handler
class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
extends Actor with ActorLogging {

import Tcp._

final case class Ack(offset: Int) extends Event
import EchoHandler._

// sign death pact: this actor terminates when connection breaks
context watch connection
Expand Down
5 changes: 3 additions & 2 deletions akka-docs/rst/scala/code/docs/io/UdpDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ object ScalaUdpDocSpec {
//#connected
case msg: String =>
connection ! UdpConnected.Send(ByteString(msg))
case d @ UdpConnected.Disconnect => connection ! d
case UdpConnected.Disconnected => context.stop(self)
case UdpConnected.Disconnect =>
connection ! UdpConnected.Disconnect
case UdpConnected.Disconnected => context.stop(self)
}
}
//#connected
Expand Down
Loading

0 comments on commit a029a90

Please sign in to comment.