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

    https://github.com/apache/spark/pull/4557#discussion_r24563933
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/rest/StandaloneRestClient.scala ---
    @@ -155,10 +156,21 @@ private[spark] class StandaloneRestClient extends 
Logging {
       /**
        * Read the response from the server and return it as a validated 
[[SubmitRestProtocolResponse]].
        * If the response represents an error, report the embedded message to 
the user.
    +   * Exposed for testing.
        */
    -  private def readResponse(connection: HttpURLConnection): 
SubmitRestProtocolResponse = {
    +  private[spark] def readResponse(connection: HttpURLConnection): 
SubmitRestProtocolResponse = {
         try {
    -      val responseJson = 
Source.fromInputStream(connection.getInputStream).mkString
    +      val dataStream =
    +        if (connection.getResponseCode == HttpServletResponse.SC_OK) {
    +          connection.getInputStream
    +        } else {
    +          connection.getErrorStream
    +        }
    +      // If the server threw an exception while writing a response, it 
will not have a body
    +      if (dataStream == null) {
    +        throw new SubmitRestProtocolException("Server returned empty body")
    +      }
    --- End diff --
    
    This fixes (2) on 
[SPARK-5760](https://issues.apache.org/jira/browse/SPARK-5760)


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