Skip to content

Commit bd3f71a

Browse files
committed
Use requre instead of if
1 parent 3d17796 commit bd3f71a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

streaming/src/main/scala/org/apache/spark/streaming/receiver/BlockGenerator.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import java.util.concurrent.{ArrayBlockingQueue, TimeUnit}
2121

2222
import scala.collection.mutable.ArrayBuffer
2323

24-
import org.apache.spark.{SparkException, Logging, SparkConf}
24+
import org.apache.spark.{Logging, SparkConf}
2525
import org.apache.spark.storage.StreamBlockId
2626
import org.apache.spark.streaming.util.RecurringTimer
27-
import org.apache.spark.util.{SystemClock, Utils}
27+
import org.apache.spark.util.SystemClock
2828

2929
/** Listener object for BlockGenerator events */
3030
private[streaming] trait BlockGeneratorListener {
@@ -80,10 +80,7 @@ private[streaming] class BlockGenerator(
8080

8181
private val clock = new SystemClock()
8282
private val blockIntervalMs = conf.getTimeAsMs("spark.streaming.blockInterval", "200ms")
83-
if (blockIntervalMs <= 0) {
84-
throw new SparkException(s"'spark.streaming.blockInterval' was set as wrong value " +
85-
s"$blockIntervalMs, it must be greater than zero.")
86-
}
83+
require(blockIntervalMs > 0 ,s"'spark.streaming.blockInterval' should be a positive value")
8784

8885
private val blockIntervalTimer =
8986
new RecurringTimer(clock, blockIntervalMs, updateCurrentBuffer, "BlockGenerator")

0 commit comments

Comments
 (0)