2015-07-20 82 views
5

如何在Scala中調試代碼Future如何調試Scala Future?

我正在使用IntelliJ。

除了記錄所有我看不到的東西。

有關如何繼續的任何建議?

EDIT1:

以下是錯誤我得到:

java.lang.IllegalAccessError: tried to access field org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.concepts$1 from class org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$GeneratedEvaluatorClass$3$1 at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$GeneratedEvaluatorClass$3$1.invoke(FileToCompile0.scala:173) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:169) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:166) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) java.lang.NoSuchFieldError: doc$1 at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$GeneratedEvaluatorClass$4$1.invoke(FileToCompile1.scala:173) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:169) at org.iadb.poolpartyconnector.conceptsrecommendation.RelevantConceptsRecommendationServicePoolPartyImpl$$anonfun$2$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3.apply(RelevantConceptsRecommendationService.scala:166) at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:397) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

我的代碼:

def filterResultsWithExtractionSettings(conceptResults: ConceptResults): ConceptResults = { 

    import system.dispatcher 

    val mylist: Iterable[Future[List[Concept]]] = for (fieldSettings <- fieldSettingsList if fieldSettings.maxConceptsExtraction > 0; doc <- conceptResults.document; concepts <- doc.concepts) yield { 

     Future { 
     val schemefiltered = concepts.withFilter(e => e.conceptSchemes.contains(fieldSettings.scheme)).flatMap(e=> List(e)) 

      schemefiltered.size match { 
      case e if e > fieldSettings.maxConceptsExtraction => schemefiltered.take(fieldSettings.maxConceptsExtraction) 
      case _ => schemefiltered 
     } 
     } 

    } 

    val res = Await.result(Future.sequence(mylist), Duration.Inf).flatten.toList 

    val distinctRes = res.distinct 

    conceptResults.copy(document = Some(conceptResults.document.get.copy(concepts = Some(distinctRes)))) 

} 
+0

好吧,只是把一個斷點就行了... –

+0

的IntelliJ調試器是越野車;我看到它導致這樣的問題('IllegalAccessError'永遠不會發生在普通代碼中)。我可以建議的是使用不同的調試器和/或提交一個最簡單的例子作爲JetBrains的錯誤報告。 – lmm

+0

你有試過嗎? http://stackoverflow.com/questions/27784413/how-to-debug-a-multi-threaded-app-in-intellij – mike

回答