You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by liyezhang556520 <gi...@git.apache.org> on 2015/04/28 08:54:29 UTC

[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

GitHub user liyezhang556520 opened a pull request:

    https://github.com/apache/spark/pull/5739

    [Core][test][minor] replace try finally block with tryWithSafeFinally

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/liyezhang556520/spark trySafeFinally

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/5739.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #5739
    
----
commit 55683e57e6c532a7c4f6bbb94f5efb8c57d11670
Author: Zhang, Liye <li...@intel.com>
Date:   2015-04-28T06:17:38Z

    replace try finally block with tryWithSafeFinally

----


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-97514876
  
    > the way you suggested may not able to get exception threw from try block
    
    If you need to catch exceptions from the `try` block, you just catch them, right?


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/5739


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by liyezhang556520 <gi...@git.apache.org>.
Github user liyezhang556520 commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-97635489
  
    Hi @vanzin, Sorry for my misleading expression. I mean, the exception threw from `try` block  is not aware in `finally` block even if it is caught by a `catch` block, and if the `finally` block also cause another exception(which is not the root cause of error, just side affection of previous exception in `try` block), this exception will not be suppressed, and the outcome error message will mixed with both exceptions thrown from `try` block and `finally` block, I think that may be a little confusing to user.


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-97882320
  
    I think you missed the part of my message where I suggested a different way to suppress the exception in the finally block that is not ridiculously ugly like the current one. No functionality changes, just syntax.


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-97143080
  
    Thanks. I've merged this.



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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-96954817
  
    Any specific reason to do this?


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by srowen <gi...@git.apache.org>.
Github user srowen commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-97026017
  
    Yeah it's pretty minor but I agree with that. In the case where both the write and close cause an exception, the original exception would not get masked.


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-96973497
  
      [Test build #31125 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/31125/consoleFull) for   PR 5739 at commit [`55683e5`](https://github.com/apache/spark/commit/55683e57e6c532a7c4f6bbb94f5efb8c57d11670).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.
     * This patch does not change any dependencies.


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5739#discussion_r29269314
  
    --- Diff: core/src/test/scala/org/apache/spark/deploy/history/FsHistoryProviderSuite.scala ---
    @@ -224,9 +224,9 @@ class FsHistoryProviderSuite extends FunSuite with BeforeAndAfter with Matchers
           EventLoggingListener.initEventLog(new FileOutputStream(file))
         }
         val writer = new OutputStreamWriter(bstream, "UTF-8")
    -    try {
    +    Utils.tryWithSafeFinally {
           events.foreach(e => writer.write(compact(render(JsonProtocol.sparkEventToJson(e))) + "\n"))
    -    } finally {
    +    } {
    --- End diff --
    
    Not your fault, but this looks super ugly. I'd favor using something like the following instead of that `Utils` method:
    
        try { 
           // code
        } finally Utils.catchAndLogExceptions {
          // finally block that may throw
        }


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-96950628
  
      [Test build #31125 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/31125/consoleFull) for   PR 5739 at commit [`55683e5`](https://github.com/apache/spark/commit/55683e57e6c532a7c4f6bbb94f5efb8c57d11670).


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by liyezhang556520 <gi...@git.apache.org>.
Github user liyezhang556520 commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-96964795
  
    @rxin, I'm just thinking it's always more reasonable to use `tryWithSafeFinally`, which can give more elegant error message. Also, all the code in other places use `tryWithSafeFinally` for writing to output together with close the output.


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


[GitHub] spark pull request: [Core][test][minor] replace try finally block ...

Posted by liyezhang556520 <gi...@git.apache.org>.
Github user liyezhang556520 commented on the pull request:

    https://github.com/apache/spark/pull/5739#issuecomment-97287644
  
    Hi @vanzin , the way you suggested may not able to get exception threw from `try` block, so that some sibling exceptions may not able to be suppressed.


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