Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #466 from Azure/legacy-dev
Browse files Browse the repository at this point in the history
Legacy dev
  • Loading branch information
rickle-msft authored Apr 23, 2019
2 parents 1afb7aa + 5260ec8 commit 4af82f0
Show file tree
Hide file tree
Showing 17 changed files with 1,140 additions and 38 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2019.04.23 Version 8.3.0
* Fixed a bug in the range download to InputStream that would throw an exception if the source blob was empty.
* Added support for List/Close File Handles APIs.

2019.04.05 Version 8.2.0
* Support for 2018-11-09 REST version. Please see our REST API documentation and blogs for information about the related added features.
* Added appendBlockFromURL method. A block may be created with another blob as its source.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.2.0</version>
<version>8.3.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion microsoft-azure-storage-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.2.0</version>
<version>8.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-storage</artifactId>
<version>8.2.0</version>
<version>8.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1990,12 +1990,30 @@ public void testBlobInputStream() throws URISyntaxException, StorageException, I
blobRef.delete();
}

@Test
@Category({ DevFabricTests.class, DevStoreTests.class })
public void testBlobInputStreamWithRangeEmptyBlob() throws URISyntaxException, StorageException, IOException {
// setup
CloudAppendBlob blob =
this.container.getAppendBlobReference(BlobTestHelper.generateRandomBlobNameWithPrefix("emptyAB"));
blob.createOrReplace();

// act
BlobInputStream stream = blob.openInputStream(0, null, null, null, null);

// assert
Assert.assertEquals(-1, stream.read());

// cleanup
stream.close();
}

@Test
@Category({ DevFabricTests.class, DevStoreTests.class })
public void testBlobInputStreamWithRange() throws StorageException, IOException, URISyntaxException {

final int blobLength = 4 * Constants.KB;
final String blobName = "testBlobInputStreamWithOffset" + UUID.randomUUID();
final String blobName = BlobTestHelper.generateRandomBlobNameWithPrefix("testBlobInputStreamWithOffset");

// setup
final CloudBlockBlob blob = this.container.getBlockBlobReference(blobName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ public void testSupportedDirectoryApisInShareSnapshot() throws StorageException,
assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2"));
assertNotNull(dir.getProperties().getEtag());
assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());

snapshotDir.listHandles();
snapshotDir.closeAllHandlesSegmented();

final UriQueryBuilder uriBuilder = new UriQueryBuilder();
uriBuilder.add("sharesnapshot", snapshot.snapshotID);
Expand Down Expand Up @@ -881,4 +884,16 @@ public void eventOccurred(SendingRequestEvent eventArg) {
directory.create();
assertFalse(directory.deleteIfExists(null, null, ctx));
}

@Test
public void testListCloseHandles() throws StorageException, URISyntaxException, InterruptedException {
CloudFileClient client = FileTestHelper.createCloudFileClient();
CloudFileDirectory directory = this.share.getRootDirectoryReference();

directory.listHandles();

directory.listHandlesSegmented(400, true, null, null, null);

directory.closeAllHandlesSegmented();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.microsoft.azure.storage.core.UriQueryBuilder;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand Down Expand Up @@ -1706,12 +1707,27 @@ public void testSupportedFileApisInShareSnapshot() throws StorageException, URIS
assertNotNull(file.getProperties().getEtag());
assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());

snapshotFile.listHandles();
snapshotFile.closeAllHandlesSegmented();

final UriQueryBuilder uriBuilder = new UriQueryBuilder();
uriBuilder.add("sharesnapshot", snapshot.snapshotID);
CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials());
assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID);
assertTrue(snapshotFile2.exists());

snapshot.delete();
}

@Test
public void testListCloseHandles() throws StorageException, URISyntaxException, InterruptedException {
CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1");
file.create(1024);

file.listHandles();

file.listHandlesSegmented(400, null, null, null);

file.closeAllHandlesSegmented();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ public static class HeaderConstants {
*/
public static final String POP_RECEIPT_HEADER = PREFIX_FOR_STORAGE_HEADER + "popreceipt";

/**
* The header that specifies recursive listing.
*/
public static final String RECURSIVE = PREFIX_FOR_STORAGE_HEADER + "recursive";

/**
* The header prefix for metadata.
*/
Expand Down Expand Up @@ -715,7 +720,7 @@ public static class HeaderConstants {
/**
* Specifies the value to use for UserAgent header.
*/
public static final String USER_AGENT_VERSION = "8.2.0";
public static final String USER_AGENT_VERSION = "8.3.0";

/**
* The default type for content-type and accept
Expand Down Expand Up @@ -782,11 +787,21 @@ public static class QueryConstants {
*/
public static final String END_ROW_KEY = "erk";

/**
* The query component for force close handles.
*/
public static final String CLOSE_HANDLES = "forceclosehandles";

/**
* Query component value for list.
*/
public static final String LIST = "list";

/**
* Query component for list handles.
*/
public static final String LIST_HANDLES = "listhandles";

/**
* Query component value for properties.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,14 @@ public enum ResultContinuationType {
* Specifies the token is a share listing continuation token.
*/
SHARE,

/**
* Specifies the token is a handle listing continuation token.
*/
HANDLE,

/**
* Specifies the token is a handle closing continuation token.
*/
HANDLE_CLOSE,
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ protected BlobInputStream(long blobRangeOffset, Long blobRangeLength, final Clou

parentBlob.downloadAttributes(accessCondition, this.options, this.opContext);

Utility.assertInBounds("blobRangeOffset", blobRangeOffset, 0, parentBlob.getProperties().getLength() - 1);
if (blobRangeLength != null) {
Utility.assertGreaterThanOrEqual("blobRangeLength", blobRangeLength, 0);
if (blobRangeOffset < 0 || (blobRangeLength != null && blobRangeLength <= 0)) {
throw new IndexOutOfBoundsException();
}

this.retrievedContentMD5Value = parentBlob.getProperties().getContentMD5();
Expand Down
Loading

0 comments on commit 4af82f0

Please sign in to comment.