Skip to content

Commit

Permalink
Merge pull request #27 from WindowsAzure/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Albert Cheng committed Mar 22, 2013
2 parents bff956b + 75d7a8c commit 42d86ee
Show file tree
Hide file tree
Showing 35 changed files with 576 additions and 196 deletions.
20 changes: 17 additions & 3 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
2013.1.18 Version 0.4.0
2013.03.12 Version 0.4.1
* Added "Azure-SDK-For-Java/<version>" To User-Agent HTTP header
* Added connection string support for Service Bus
* Added new methods to break lease for Storage Blob which doesn't require a lease id and returns the result as an object. Deprecated the old breakLease() methods.
* Added a new method to get the historical events for Media Services
* Fixed Storage Table encoding issue for special characters
* BlobOutputStream now commits block list using LATEST instead of UNCOMMITTED
* Added RequestResult to StorageEvents
* Fixed issue when accessing OperationContext RequestResults
* Fixed the return value of BlobInputStream.read
* Fixed CloudPageBlob.downloadPageRanges to retrieve the blob length
* Fixed MD5 validation in BlobInputStream
* Return ETag in TableResult not only for Insert but also for other operations

2013.01.18 Version 0.4.0
* Added support for Windows Azure Media Services
* Updated dependencies to non-beta stable versions
* Add a Sending Request Event to OperationContext in Storage Client code
* Fix a bug in the STorage client in blob download resume for blobs greater than 2GB
* Added a Sending Request Event to OperationContext in Storage Client code
* Fixed a bug in the Storage client in blob download resume for blobs greater than 2GB

2012.10.29 Version 0.3.3
* In the blob client, fixed a bug which allows users to call write APIs on a blob snapshot reference
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ within your project you can also have them installed by the Java package manager
<dependency>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>

##Minimum Requirements
Expand Down
2 changes: 1 addition & 1 deletion microsoft-azure-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.windowsazure</groupId>
<artifactId>microsoft-windowsazure-api</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
<packaging>jar</packaging>

<name>Microsoft Windows Azure Client API</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public final class BlobInputStream extends InputStream {
*/
private boolean validateBlobMd5;

/**
* Holds the Blob MD5.
*/
private final String retrievedContentMD5Value;

/**
* Holds the reference to the current buffered data.
*/
Expand Down Expand Up @@ -161,11 +166,11 @@ protected BlobInputStream(final CloudBlob parentBlob, final AccessCondition acce

final HttpURLConnection attributesRequest = this.opContext.getCurrentRequestObject();

final String retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5);
this.retrievedContentMD5Value = attributesRequest.getHeaderField(Constants.HeaderConstants.CONTENT_MD5);

// Will validate it if it was returned
this.validateBlobMd5 = !options.getDisableContentMD5Validation()
&& !Utility.isNullOrEmpty(retrievedContentMD5Value);
&& !Utility.isNullOrEmpty(this.retrievedContentMD5Value);

// Validates the first option, and sets future requests to use if match
// request option.
Expand Down Expand Up @@ -395,8 +400,17 @@ public boolean markSupported() {
@DoesServiceRequest
public int read() throws IOException {
final byte[] tBuff = new byte[1];
this.read(tBuff, 0, 1);
return tBuff[0];
final int numberOfBytesRead = this.read(tBuff, 0, 1);

if (numberOfBytesRead > 0) {
return tBuff[0] & 0xFF;
}
else if (numberOfBytesRead == 0) {
throw new IOException("Unexpected error. Stream returned unexpected number of bytes.");
}
else {
return -1;
}
}

/**
Expand Down Expand Up @@ -519,13 +533,13 @@ private synchronized int readInternal(final byte[] b, final int off, int len) th
if (this.currentAbsoluteReadPosition == this.streamLength) {
// Reached end of stream, validate md5.
final String calculatedMd5 = Base64.encode(this.md5Digest.digest());
if (!calculatedMd5.equals(this.parentBlobRef.getProperties().getContentMD5())) {
if (!calculatedMd5.equals(this.retrievedContentMD5Value)) {
this.lastError = Utility
.initIOException(new StorageException(
StorageErrorCodeStrings.INVALID_MD5,
String.format(
"Blob data corrupted (integrity check failed), Expected value is %s, retrieved %s",
this.parentBlobRef.getProperties().getContentMD5(), calculatedMd5),
this.retrievedContentMD5Value, calculatedMd5),
Constants.HeaderConstants.HTTP_UNUSED_306, null, null));
this.streamFaulted = true;
throw this.lastError;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ private synchronized void dispatchWrite(final int writeLength) throws IOExceptio
if (this.streamType == BlobType.BLOCK_BLOB) {
final CloudBlockBlob blobRef = (CloudBlockBlob) this.parentBlobRef;
final String blockID = Base64.encode(Utility.getBytesFromLong(this.blockIdSequenceNumber++));
this.blockList.add(new BlockEntry(blockID, BlockSearchMode.UNCOMMITTED));
this.blockList.add(new BlockEntry(blockID, BlockSearchMode.LATEST));

worker = new Callable<Void>() {
@Override
Expand Down
Loading

0 comments on commit 42d86ee

Please sign in to comment.