Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ba413e1772ffb8b118f7d097f593d8da0ac31dd2
Author: Louis DeJardin <lodejard@microsoft.com>
Date:   Thu Dec 22 14:54:57 2011 -0800

    Updating version number

    Also updates javadoc copyright

commit f00a816259c8153a70b05e1f94ff2d78bed00634
Author: Joe Giardino <joegiard@microsoft.com>
Date:   Tue Dec 20 11:51:18 2011 -0800

    AccessCondition null check

commit 5768257af578aae6fe363adf1bb1b4a7690ef4f3
Author: Joe Giardino <joegiard@microsoft.com>
Date:   Tue Dec 20 11:29:28 2011 -0800

    CloudBlob Fix: Ensure Client side exceptions are not resumed

commit 78d3abb95837ef4e81be925b771c07100c1c1c09
Author: Joe Giardino <joegiard@microsoft.com>
Date:   Tue Dec 20 10:55:00 2011 -0800

    CloudBlob Fix: Ensure Client side exceptions are not resumed

commit 77364329532c2443854d26e813171245507a284b
Author: Joe Giardino <joegiard@microsoft.com>
Date:   Mon Dec 19 16:07:46 2011 -0800

    (Hotfix: Update CloudBlob.download to lock to etag during a resume. Extended Error null fix.)

commit 3df01b929132dcf2445b33d98a213d26cdf7364b
Author: Joe Giardino <joegiard@microsoft.com>
Date:   Mon Dec 19 16:04:26 2011 -0800

    Hotfix: Update CloudBlob.download to lock to etag during a resume. Extended Error null fix.

    Signed-off-by: Joe Giardino <joegiard@microsoft.com>

commit c0c64239a3fddb7e07e40c65a0a8fee43a29423c
Author: Renaud Paquay <renaud.paquay@microsoft.com>
Date:   Wed Dec 14 11:29:13 2011 -0800

    Update version #
  • Loading branch information
lodejard committed Dec 22, 2011
1 parent 98b4695 commit 3af206a
Show file tree
Hide file tree
Showing 4 changed files with 399 additions and 434 deletions.
23 changes: 22 additions & 1 deletion microsoft-azure-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.1.0</version>
<version>0.1.2</version>
<packaging>jar</packaging>

<name>Microsoft Windows Azure Client API</name>
Expand All @@ -28,6 +28,13 @@
<legal><![CDATA[[INFO] Any downloads listed may be third party software. Microsoft grants you no rights for third party software.]]></legal>
</properties>

<developers>
<developer>
<id>microsoft</id>
<name>Microsoft</name>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
Expand Down Expand Up @@ -138,6 +145,20 @@
<version>2.8</version>
<configuration>
<excludePackageNames>*.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization</excludePackageNames>
<bottom><![CDATA[<code>/**
<br/>* Copyright 2011 Microsoft Corporation
<br/>*
<br/>* Licensed under the Apache License, Version 2.0 (the "License");
<br/>* you may not use this file except in compliance with the License.
<br/>* You may obtain a copy of the License at
<br/>* http://www.apache.org/licenses/LICENSE-2.0
<br/>*
<br/>* Unless required by applicable law or agreed to in writing, software
<br/>* distributed under the License is distributed on an "AS IS" BASIS,
<br/>* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<br/>* See the License for the specific language governing permissions and
<br/>* limitations under the License.
<br/>*/</code>]]></bottom>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.blob.client;

Expand All @@ -37,6 +37,7 @@
import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature;
import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings;
import com.microsoft.windowsazure.services.core.storage.StorageException;
import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation;
import com.microsoft.windowsazure.services.core.storage.utils.Base64;
import com.microsoft.windowsazure.services.core.storage.utils.PathUtility;
import com.microsoft.windowsazure.services.core.storage.utils.StreamMd5AndLength;
Expand Down Expand Up @@ -807,17 +808,16 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op
final String contentLength = request.getHeaderField(Constants.HeaderConstants.CONTENT_LENGTH);
final long expectedLength = Long.parseLong(contentLength);

final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false,
validateMD5, this.getResult(), opContext);

blob.updatePropertiesFromResponse(request);
ExecutionEngine.getResponseCode(this.getResult(), request, opContext);

if (this.getResult().getStatusCode() != HttpURLConnection.HTTP_OK) {
this.setNonExceptionedRetryableFailure(true);
return null;
}

blob.updatePropertiesFromResponse(request);
final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false,
validateMD5, this.getResult(), opContext);

if (descriptor.getLength() != expectedLength) {
throw new StorageException(
Expand All @@ -843,10 +843,12 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op
opContext.setIntermediateMD5(null);
}
catch (final StorageException ex) {
// Check if users has any retries specified.
// Check if users has any retries specified, Or if the exception is retryable
final RetryPolicy dummyPolicy = options.getRetryPolicyFactory().createInstance(opContext);
if (!dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(), (Exception) ex.getCause(),
opContext).isShouldRetry()) {
if (ex.getHttpStatusCode() == Constants.HeaderConstants.HTTP_UNUSED_306
|| ex.getHttpStatusCode() == HttpURLConnection.HTTP_PRECON_FAILED
|| !dummyPolicy.shouldRetry(0, opContext.getLastResult().getStatusCode(),
(Exception) ex.getCause(), opContext).isShouldRetry()) {
opContext.setIntermediateMD5(null);
throw ex;
}
Expand All @@ -855,8 +857,17 @@ public Void execute(final CloudBlobClient client, final CloudBlob blob, final Op
// be outside the operation above as it would get retried resulting
// in a nested retry

// Copy access condition, and update etag. This will potentially replace the if match value, but not on the
// users object.

AccessCondition etagLockCondition = new AccessCondition();
etagLockCondition.setIfMatch(this.getProperties().getEtag());
if (accessCondition != null) {
etagLockCondition.setLeaseID(accessCondition.getLeaseID());
}

// 1. Open Read Stream
final BlobInputStream streamRef = this.openInputStream(accessCondition, options, opContext);
final BlobInputStream streamRef = this.openInputStream(etagLockCondition, options, opContext);

// Cache value indicating if we need
final boolean validateMd5 = streamRef.getValidateBlobMd5();
Expand Down Expand Up @@ -2029,8 +2040,15 @@ public Long execute(final CloudBlobClient client, final CloudBlob blob, final Op
final StorageException potentialConflictException = StorageException.translateException(request,
null, opContext);

if (!potentialConflictException.getExtendedErrorInformation().getErrorCode()
.equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) {
StorageExtendedErrorInformation extendedInfo = potentialConflictException
.getExtendedErrorInformation();

if (extendedInfo == null) {
// If we cant validate the error then the error must be surfaced to the user.
throw potentialConflictException;
}

if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.LEASE_ALREADY_BROKEN)) {
this.setException(potentialConflictException);
this.setNonExceptionedRetryableFailure(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
* Copyright 2011 Microsoft Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.microsoft.windowsazure.services.blob.client;

Expand All @@ -37,6 +37,7 @@
import com.microsoft.windowsazure.services.core.storage.StorageCredentialsSharedAccessSignature;
import com.microsoft.windowsazure.services.core.storage.StorageErrorCodeStrings;
import com.microsoft.windowsazure.services.core.storage.StorageException;
import com.microsoft.windowsazure.services.core.storage.StorageExtendedErrorInformation;
import com.microsoft.windowsazure.services.core.storage.utils.PathUtility;
import com.microsoft.windowsazure.services.core.storage.utils.UriQueryBuilder;
import com.microsoft.windowsazure.services.core.storage.utils.Utility;
Expand Down Expand Up @@ -309,8 +310,14 @@ else if (this.getResult().getStatusCode() == HttpURLConnection.HTTP_CONFLICT) {
final StorageException potentialConflictException = StorageException.translateException(request,
null, opContext);

if (!potentialConflictException.getExtendedErrorInformation().getErrorCode()
.equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) {
StorageExtendedErrorInformation extendedInfo = potentialConflictException
.getExtendedErrorInformation();
if (extendedInfo == null) {
// If we can't validate the error then the error must be surfaced to the user.
throw potentialConflictException;
}

if (!extendedInfo.getErrorCode().equals(StorageErrorCodeStrings.CONTAINER_ALREADY_EXISTS)) {
this.setException(potentialConflictException);
this.setNonExceptionedRetryableFailure(true);

Expand Down
Loading

0 comments on commit 3af206a

Please sign in to comment.