Re: [akka-user] Akka Stream - ExecutionException: Boxed Error

320 views
Skip to first unread message

Patrik Nordwall

unread,
Nov 28, 2014, 1:49:33 PM11/28/14
to akka...@googlegroups.com
Could you also try

val done = source.runWith(sink)
done.onComplete ....

You use version 0.11, right?

What is the full stackTrace?
Try to grab the getCause of the ExecutionException.

/Patrik

28 nov 2014 kl. 15:25 skrev Bertil Chapuis <bcha...@agimem.com>:

Hi,

I'm playing with Akka Stream and trying to define a Source that listen to file system events with the java nio WatchService.

import java.nio.file.StandardWatchEventKinds._
import java.nio.file._

import akka.actor.ActorSystem
import akka.stream.FlowMaterializer
import akka.stream.scaladsl._

import scala.util.{Failure, Success}

object Main extends App {

  implicit val system = ActorSystem()
  import system.dispatcher
  implicit val materializer = FlowMaterializer()

  val dir = Paths.get("/tmp")
  val watcher = FileSystems.getDefault().newWatchService()

  dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY)

  val source = Source(() => Some(watcher.poll())).filter(key => key != null)

  val sink = ForeachSink[WatchKey](key => {
    println(key)
    Thread.sleep(1000)
  })

  val materialized = FlowGraph { implicit builder =>
    import akka.stream.scaladsl.FlowGraphImplicits._
    source ~> sink
  }.run()

  materialized.get(sink).onComplete {
    case Success(_) =>
      system.shutdown()
    case Failure(e) =>
      println(e)
      system.shutdown()
  }

}

When I try to filter the source to exclude null watch keys, I get the following exception:

java.util.concurrent.ExecutionException: Boxed Error

Any ideas regarding this problem?

Regards,

Bertil

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages