Github user taoli91 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12693#discussion_r61987150
  
    --- Diff: 
core/src/test/scala/org/apache/spark/scheduler/EventLoggingListenerSuite.scala 
---
    @@ -202,33 +202,37 @@ class EventLoggingListenerSuite extends SparkFunSuite 
with LocalSparkContext wit
     
         // Make sure expected events exist in the log file.
         val logData = EventLoggingListener.openEventLog(new 
Path(eventLogger.logPath), fileSystem)
    -    val logStart = SparkListenerLogStart(SPARK_VERSION)
    -    val lines = readLines(logData)
    -    val eventSet = mutable.Set(
    -      SparkListenerApplicationStart,
    -      SparkListenerBlockManagerAdded,
    -      SparkListenerExecutorAdded,
    -      SparkListenerEnvironmentUpdate,
    -      SparkListenerJobStart,
    -      SparkListenerJobEnd,
    -      SparkListenerStageSubmitted,
    -      SparkListenerStageCompleted,
    -      SparkListenerTaskStart,
    -      SparkListenerTaskEnd,
    -      SparkListenerApplicationEnd).map(Utils.getFormattedClassName)
    -    lines.foreach { line =>
    -      eventSet.foreach { event =>
    -        if (line.contains(event)) {
    -          val parsedEvent = JsonProtocol.sparkEventFromJson(parse(line))
    -          val eventType = Utils.getFormattedClassName(parsedEvent)
    -          if (eventType == event) {
    -            eventSet.remove(event)
    +    try {
    +      val logStart = SparkListenerLogStart(SPARK_VERSION)
    +      val lines = readLines(logData)
    --- End diff --
    
    I tried:
    ```scala
        val logData = EventLoggingListener.openEventLog(new 
Path(eventLogger.logPath), fileSystem)
        var lines : Seq[String] = null
        try {
          lines = readLines(logData)
        } finally {
          logData.close()
        }
    ```
    
    It thrown IOException complaining that Stream closed. 
    
    I think the readLines is sort of lazy such that it won't read the file 
until we actually move the iterator. 



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to