Skip to content

DefaultErrorResponseHandler masks true exception when service returns invalid XML #40

Closed
@garnold

Description

We are seeing an issue where calls to AmazonElasticMapReduceClient#runJobFlow intermittently fail with the following stack trace:

Caused by: com.amazonaws.AmazonClientException: Unable to unmarshall error response (Premature end of file.)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:548)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:290)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:170)
        at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.invoke(AmazonElasticMapReduceClient.java:574)
        at com.amazonaws.services.elasticmapreduce.AmazonElasticMapReduceClient.runJobFlow(AmazonElasticMapReduceClient.java:432)
        at 
<snip/>
        ... 3 more
Caused by: org.xml.sax.SAXParseException: Premature end of file.
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)
        at com.amazonaws.util.XpathUtils.documentFrom(XpathUtils.java:67)
        at com.amazonaws.http.DefaultErrorResponseHandler.handle(DefaultErrorResponseHandler.java:65)
        at com.amazonaws.http.DefaultErrorResponseHandler.handle(DefaultErrorResponseHandler.java:36)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:528)
        ... 14 more

However, because DefaultErrorResponseHandler is failing to parse the (presumably invalid) XML returned from the service, we cannot determine the root cause of the issue. Perhaps in these cases the DefaultErrorResponseHandler should trap the SAXParseException thrown by XpathUtils#documentFrom and either log the raw HttpResponse content or at the very least throw an AmazonServiceException containing that HTTP status code to provide a hint as to the real issue.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions