Github user lw-lin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17070#discussion_r103102422
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/HDFSMetadataLog.scala
 ---
    @@ -268,6 +274,37 @@ class HDFSMetadataLog[T <: AnyRef : 
ClassTag](sparkSession: SparkSession, path:
             new FileSystemManager(metadataPath, hadoopConf)
         }
       }
    +
    +  /**
    +   * Parse the log version from the given `text` -- will throw exception 
when the parsed version
    +   * exceeds `maxSupportedVersion`, or when `text` is malformed (such as 
"xyz", "v", "v-1",
    +   * "v123xyz" etc.)
    +   */
    +  private[sql] def parseVersion(text: String, maxSupportedVersion: Int): 
Int = {
    +    if (text.length > 0 && text(0) == 'v') {
    +      val version =
    +        try { text.substring(1, text.length).toInt }
    +        catch {
    +          case _: NumberFormatException =>
    +            throw new IllegalStateException(s"Log file was malformed: 
failed to read correct log " +
    +              s"version from $text.")
    +        }
    +      if (version > 0) {
    +        if (version > maxSupportedVersion) {
    +          throw new IllegalStateException(s"UnsupportedLogVersion: maximum 
supported log version " +
    +            s"is v${maxSupportedVersion}, but encountered v$version. The 
log file was produced " +
    +            s"by a newer version of Spark and cannot be read by this 
version. Please upgrade.")
    +        }
    +        else {
    --- End diff --
    
    done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to