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

    https://github.com/apache/spark/pull/14907#discussion_r77099874
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JDBCRDD.scala
 ---
    @@ -546,33 +281,33 @@ private[jdbc] class JDBCRDD(
           closed = true
         }
     
    -    override def hasNext: Boolean = {
    -      if (!finished) {
    -        if (!gotNext) {
    -          nextValue = getNext()
    -          if (finished) {
    -            close()
    -          }
    -          gotNext = true
    -        }
    -      }
    -      !finished
    -    }
    +    context.addTaskCompletionListener{ context => close() }
    --- End diff --
    
    Note that `close()` is idempotent because it may be called twice, at the 
end of the task and at the end of iteration. In the old code the 
end-of-iteration case was handled in `hasNext`; here, it's handled in a 
`CompletionIterator` defined below.


---
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