You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rxin <gi...@git.apache.org> on 2014/08/05 22:51:44 UTC

[GitHub] spark pull request: SPARK-2869 - Potential leak of Jdbc Connection...

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

    https://github.com/apache/spark/pull/1792#discussion_r15840899
  
    --- Diff: core/src/main/scala/org/apache/spark/rdd/JdbcRDD.scala ---
    @@ -70,20 +70,30 @@ class JdbcRDD[T: ClassTag](
       override def compute(thePart: Partition, context: TaskContext) = new NextIterator[T] {
         context.addOnCompleteCallback{ () => closeIfNeeded() }
         val part = thePart.asInstanceOf[JdbcPartition]
    -    val conn = getConnection()
    -    val stmt = conn.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)
    +    var conn : Connection = _
    +    var stmt : PreparedStatement = _
    +    try {
    --- End diff --
    
    Actually as I look at this again, I think the try is not necessary. Basically the first line in the constructor adds "closeIfNeeded" callback to the complete callback list. Then if any exception is thrown, even during the constructor, I think closeIfNeeded is called to close connections.
    
    



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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