Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Storage ExecutionEngine.executeWithRetry with error in exception handling #297

Closed
JMayrbaeurl opened this Issue · 3 comments

5 participants

@JMayrbaeurl

The method com.microsoft.windowsazure.services.core.storage.utils.implementation.ExecutionEngine.executeWithRetry(CLIENT_TYPE, PARENT_TYPE, StorageOperation, RetryPolicyFactory, OperationContext) indirectly uses com.microsoft.windowsazure.services.core.storage.StorageException.getErrorDetailsFromRequest(HttpURLConnection, OperationContext) in case of IOException handling (line 147 in the source file for ExecutionEngine) that doesn't check the errorResponse stream from the HTTP request. In case of e.g. time outs, the errorResponse stream can be null, causing a 'java.lang.IllegalArgumentException: Null InputStream is not a valid argument' at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:614).

Can be easily fixed by changing com.microsoft.windowsazure.services.core.storage.StorageException.getErrorDetailsFromRequest(HttpURLConnection, OperationContext) to:

protected static StorageExtendedErrorInformation getErrorDetailsFromRequest(final HttpURLConnection request,
        final OperationContext opContext) {
    if (request == null) {
        return null;
    }
    try {
        // First check the existence of an error stream
        InputStream err = request.getErrorStream();
        if (err != null) {
            final StorageErrorResponse response = new StorageErrorResponse(request.getErrorStream());
            return response.getExtendedErrorInformation();
        }
        else
            return null;
    }
    catch (final XMLStreamException e) {
        return null;
    }
}

BTW. The root cause is that com.microsoft.windowsazure.services.core.storage.utils.implementation.StorageErrorResponse.StorageErrorResponse(InputStream) doesn't check the input parameter for null values

@JMayrbaeurl

Root cause of the problem comes from using other XML stream reader implementations than the default one from the standard Java SDK. E.g. with Woodstox (see http://woodstox.codehaus.org/, quite popular) you'll get an IllegalArgumentException, if you pass null as the value for the input stream on creating a XML stream reader.

@JMayrbaeurl JMayrbaeurl referenced this issue from a commit in JMayrbaeurl/azure-sdk-for-java
@JMayrbaeurl JMayrbaeurl Fixes issue #297 Storage ExecutionEngine.executeWithRetry with error in
exception handling
f8d591c
@guangyang
Collaborator

@jeffreyjirwin please take a look.

@andrerod andrerod closed this
@azuresdkci azuresdkci removed this from the Backlog milestone
@azuresdkci azuresdkci removed the storage label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.