{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/12272","repository_url":"https://api.github.com/repos/apache/spark","labels_url":"https://api.github.com/repos/apache/spark/issues/12272/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/12272/comments","events_url":"https://api.github.com/repos/apache/spark/issues/12272/events","html_url":"https://github.com/apache/spark/pull/12272","id":147100105,"number":12272,"title":"[SPARK-14454][1.6] Better exception handling while marking tasks as failed","user":{"login":"sameeragarwal","id":166454,"avatar_url":"https://avatars.githubusercontent.com/u/166454?v=3","gravatar_id":"","url":"https://api.github.com/users/sameeragarwal","html_url":"https://github.com/sameeragarwal","followers_url":"https://api.github.com/users/sameeragarwal/followers","following_url":"https://api.github.com/users/sameeragarwal/following{/other_user}","gists_url":"https://api.github.com/users/sameeragarwal/gists{/gist_id}","starred_url":"https://api.github.com/users/sameeragarwal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sameeragarwal/subscriptions","organizations_url":"https://api.github.com/users/sameeragarwal/orgs","repos_url":"https://api.github.com/users/sameeragarwal/repos","events_url":"https://api.github.com/users/sameeragarwal/events{/privacy}","received_events_url":"https://api.github.com/users/sameeragarwal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-04-09T07:05:00Z","updated_at":"2016-04-10T04:50:00Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/12272","html_url":"https://github.com/apache/spark/pull/12272","diff_url":"https://github.com/apache/spark/pull/12272.diff","patch_url":"https://github.com/apache/spark/pull/12272.patch"},"body":"Backports https://github.com/apache/spark/pull/12234 to 1.6. Original description below:\r\n\r\n## What changes were proposed in this pull request?\r\n\r\nThis patch adds support for better handling of exceptions inside catch blocks if the code within the block throws an exception. For instance here is the code in a catch block before this change in `WriterContainer.scala`: \r\n\r\n```scala\r\nlogError(\"Aborting task.\", cause)\r\n// call failure callbacks first, so we could have a chance to cleanup the writer.\r\nTaskContext.get().asInstanceOf[TaskContextImpl].markTaskFailed(cause)\r\nif (currentWriter != null) {\r\n  currentWriter.close()\r\n}\r\nabortTask()\r\nthrow new SparkException(\"Task failed while writing rows.\", cause)\r\n```\r\n\r\nIf `markTaskFailed` or `currentWriter.close` throws an exception, we currently lose the original cause. This PR fixes this problem by implementing a utility function `Utils.tryWithSafeCatch` that suppresses (`Throwable.addSuppressed`) the exception that are thrown within the catch block and rethrowing the original exception.\r\n\r\n## How was this patch tested?\r\n\r\nNo new functionality added"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/207917700","html_url":"https://github.com/apache/spark/pull/12272#issuecomment-207917700","issue_url":"https://api.github.com/repos/apache/spark/issues/12272","id":207917700,"user":{"login":"SparkQA","id":8108735,"avatar_url":"https://avatars.githubusercontent.com/u/8108735?v=3","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2016-04-10T04:50:00Z","updated_at":"2016-04-10T04:50:00Z","body":"**[Test build #2773 has finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/2773/consoleFull)** for PR 12272 at commit [`0defe22`](https://github.com/apache/spark/commit/0defe220b3f6df7979483ce5959e5485e56353c6).\n * This patch **fails build dependency tests**.\n * This patch merges cleanly.\n * This patch adds no public classes."}}