From e29704f90dfe67d9e276d242699ac0a00f64fb91 Mon Sep 17 00:00:00 2001 From: bomeng Date: Thu, 10 Dec 2015 12:53:53 +0000 Subject: [SPARK-12136][STREAMING] rddToFileName does not properly handle prefix and suffix parameters The original code does not properly handle the cases where the prefix is null, but suffix is not null - the suffix should be used but is not. The fix is using StringBuilder to construct the proper file name. Author: bomeng Author: Bo Meng Closes #10185 from bomeng/SPARK-12136. --- .../scala/org/apache/spark/streaming/StreamingContext.scala | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'streaming/src/main') diff --git a/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala b/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala index cf843e3e8b..b24c0d067b 100644 --- a/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala +++ b/streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala @@ -892,12 +892,13 @@ object StreamingContext extends Logging { } private[streaming] def rddToFileName[T](prefix: String, suffix: String, time: Time): String = { - if (prefix == null) { - time.milliseconds.toString - } else if (suffix == null || suffix.length ==0) { - prefix + "-" + time.milliseconds - } else { - prefix + "-" + time.milliseconds + "." + suffix + var result = time.milliseconds.toString + if (prefix != null && prefix.length > 0) { + result = s"$prefix-$result" + } + if (suffix != null && suffix.length > 0) { + result = s"$result.$suffix" } + result } } -- cgit v1.2.3