You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packagees.ucm.fdi.sscheck.spark.demoimportorg.apache.spark.rdd.RDDimportorg.apache.spark.streaming.Durationimportorg.apache.spark.streaming.dstream.DStreamimportorg.junit.runner.RunWithimportorg.scalacheck.Gen.constimportorg.specs2.ScalaCheckimportorg.specs2.Specificationimportorg.specs2.matcher.ResultMatchersimportorg.specs2.runner.JUnitRunnerimportes.ucm.fdi.sscheck.gen.BatchGenimportes.ucm.fdi.sscheck.prop.tl.DStreamPropimportes.ucm.fdi.sscheck.prop.tl.Formulaimportes.ucm.fdi.sscheck.prop.tl.Formula.alwaysimportes.ucm.fdi.sscheck.prop.tl.Formula.intToTimeoutimportes.ucm.fdi.sscheck.prop.tl.Formula.resultFunToNowimportes.ucm.fdi.sscheck.spark.streaming.SharedStreamingContextBeforeAfterEach@RunWith(classOf[JUnitRunner])
classNPEAlwaysBugextendsSpecificationwithSharedStreamingContextBeforeAfterEachwithResultMatchers// with SerializablewithScalaCheck {
// Spark configurationoverridedefsparkMaster:String="local[*]"overridedefbatchDuration=Duration(500)
overridedefdefaultParallelism=3// this is needed to reproduce the bugoverridedefenableCheckpointing=truedefis=
sequential ^s2""" - where $p1
"""// - where ${p1 must beFailing}defgenNPE=BatchGen.always(BatchGen.ofN(1, 0))
defgenOk=BatchGen.always(BatchGen.ofN(1, 0), 5)
defp1= {
typeU= (RDD[Int], RDD[Int])
valhashtagBatch= (_ : U)._2
valformula:Formula[U] = always { u : U=>true
} during 10DStreamProp.forAll(
genNPE)( // NullPointerException, see below//genOk)( // workd ok
identity[DStream[Int]])(
formula)
}.set(minTestsOk =2).verbose
/* java.lang.NullPointerException at es.ucm.fdi.sscheck.prop.tl.DStreamProp$$anonfun$forAll$4.apply(DStreamProp.scala:178) at es.ucm.fdi.sscheck.prop.tl.DStreamProp$$anonfun$forAll$4.apply(DStreamProp.scala:131) at org.scalacheck.Prop$$anonfun$forAllNoShrink$1$$anonfun$2.apply(Prop.scala:516) at org.scalacheck.Prop$.secure(Prop.scala:458) at org.scalacheck.Prop$$anonfun$forAllNoShrink$1.apply(Prop.scala:516) at org.scalacheck.Prop$$anonfun$forAllNoShrink$1.apply(Prop.scala:511) at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:293) at org.scalacheck.Prop$$anonfun$apply$5.apply(Prop.scala:292) at org.scalacheck.PropFromFun.apply(Prop.scala:21) at org.scalacheck.Test$.org$scalacheck$Test$$workerFun$1(Test.scala:321) at org.scalacheck.Test$$anonfun$2.apply(Test.scala:350) at org.scalacheck.Test$$anonfun$2.apply(Test.scala:350) at org.scalacheck.Platform$.runWorkers(Platform.scala:40) at org.scalacheck.Test$.check(Test.scala:350) at es.ucm.fdi.sscheck.spark.demo.NPEAlwaysBug.check(NPEAlwaysBug.scala:23)The problem is that genNPE is defined as BatchGen.always(BatchGen.ofN(1, 0)) whichis not a sized generator. Hence ScalaCheck starts from Gen.resize(0, genNPE) that generates PDStream(), and so the for (i <- 1 to testCaseDstream.length if (! propFailed)) in the body of Prop.forAllNoShrink inside DStreamProp.forAll doesn't make any iterationbecause testCaseDstream is an empty prefix with no batches, and so there is no wait on to onBatchCompletedSyncVar.take(batchCompletionTimeout). As a consequence inputDStream1.foreachRDD { (input1Batch, time) => ...} above is never executedand currFormula is never assigned formulaNext, so when val testCaseResult = currFormula.result.getOrElse(Prop.Undecided)is executed we get a NPE because currFormula is null.Possible fixes: - replace val testCaseResult = currFormula.result.getOrElse(Prop.Undecided) by a code that considers the case when testCaseResult is null - initialize currFormula to formulaNext instead of to a null. This looks like a good idea anyway * **/
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: