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

Commit 5260ec8

Browse files
authored
Merge pull request #465 from rickle-msft/legacy-dev
Legacy dev
2 parents 1375dbe + c4fc3f1 commit 5260ec8

File tree

17 files changed

+1140
-38
lines changed

17 files changed

+1140
-38
lines changed

ChangeLog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2019.04.23 Version 8.3.0
2+
* Fixed a bug in the range download to InputStream that would throw an exception if the source blob was empty.
3+
* Added support for List/Close File Handles APIs.
4+
15
2019.04.05 Version 8.2.0
26
* Support for 2018-11-09 REST version. Please see our REST API documentation and blogs for information about the related added features.
37
* Added appendBlockFromURL method. A block may be created with another blob as its source.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
3939
<dependency>
4040
<groupId>com.microsoft.azure</groupId>
4141
<artifactId>azure-storage</artifactId>
42-
<version>8.2.0</version>
42+
<version>8.3.0</version>
4343
</dependency>
4444
```
4545

microsoft-azure-storage-samples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>8.2.0</version>
29+
<version>8.3.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-samples/src/com/microsoft/azure/storage/logging/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.microsoft.azure</groupId>
2828
<artifactId>azure-storage</artifactId>
29-
<version>8.2.0</version>
29+
<version>8.3.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

microsoft-azure-storage-test/src/com/microsoft/azure/storage/blob/CloudBlockBlobTests.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,12 +1990,30 @@ public void testBlobInputStream() throws URISyntaxException, StorageException, I
19901990
blobRef.delete();
19911991
}
19921992

1993+
@Test
1994+
@Category({ DevFabricTests.class, DevStoreTests.class })
1995+
public void testBlobInputStreamWithRangeEmptyBlob() throws URISyntaxException, StorageException, IOException {
1996+
// setup
1997+
CloudAppendBlob blob =
1998+
this.container.getAppendBlobReference(BlobTestHelper.generateRandomBlobNameWithPrefix("emptyAB"));
1999+
blob.createOrReplace();
2000+
2001+
// act
2002+
BlobInputStream stream = blob.openInputStream(0, null, null, null, null);
2003+
2004+
// assert
2005+
Assert.assertEquals(-1, stream.read());
2006+
2007+
// cleanup
2008+
stream.close();
2009+
}
2010+
19932011
@Test
19942012
@Category({ DevFabricTests.class, DevStoreTests.class })
19952013
public void testBlobInputStreamWithRange() throws StorageException, IOException, URISyntaxException {
19962014

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

20002018
// setup
20012019
final CloudBlockBlob blob = this.container.getBlockBlobReference(blobName);

microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileDirectoryTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ public void testSupportedDirectoryApisInShareSnapshot() throws StorageException,
533533
assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2"));
534534
assertNotNull(dir.getProperties().getEtag());
535535
assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());
536+
537+
snapshotDir.listHandles();
538+
snapshotDir.closeAllHandlesSegmented();
536539

537540
final UriQueryBuilder uriBuilder = new UriQueryBuilder();
538541
uriBuilder.add("sharesnapshot", snapshot.snapshotID);
@@ -881,4 +884,16 @@ public void eventOccurred(SendingRequestEvent eventArg) {
881884
directory.create();
882885
assertFalse(directory.deleteIfExists(null, null, ctx));
883886
}
887+
888+
@Test
889+
public void testListCloseHandles() throws StorageException, URISyntaxException, InterruptedException {
890+
CloudFileClient client = FileTestHelper.createCloudFileClient();
891+
CloudFileDirectory directory = this.share.getRootDirectoryReference();
892+
893+
directory.listHandles();
894+
895+
directory.listHandlesSegmented(400, true, null, null, null);
896+
897+
directory.closeAllHandlesSegmented();
898+
}
884899
}

microsoft-azure-storage-test/src/com/microsoft/azure/storage/file/CloudFileTests.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.microsoft.azure.storage.core.UriQueryBuilder;
4242

4343
import org.junit.After;
44+
import org.junit.Assert;
4445
import org.junit.Before;
4546
import org.junit.Test;
4647
import org.junit.experimental.categories.Category;
@@ -1706,12 +1707,27 @@ public void testSupportedFileApisInShareSnapshot() throws StorageException, URIS
17061707
assertNotNull(file.getProperties().getEtag());
17071708
assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());
17081709

1710+
snapshotFile.listHandles();
1711+
snapshotFile.closeAllHandlesSegmented();
1712+
17091713
final UriQueryBuilder uriBuilder = new UriQueryBuilder();
17101714
uriBuilder.add("sharesnapshot", snapshot.snapshotID);
17111715
CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials());
17121716
assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID);
17131717
assertTrue(snapshotFile2.exists());
1714-
1718+
17151719
snapshot.delete();
17161720
}
1721+
1722+
@Test
1723+
public void testListCloseHandles() throws StorageException, URISyntaxException, InterruptedException {
1724+
CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1");
1725+
file.create(1024);
1726+
1727+
file.listHandles();
1728+
1729+
file.listHandlesSegmented(400, null, null, null);
1730+
1731+
file.closeAllHandlesSegmented();
1732+
}
17171733
}

microsoft-azure-storage/src/com/microsoft/azure/storage/Constants.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,11 @@ public static class HeaderConstants {
580580
*/
581581
public static final String POP_RECEIPT_HEADER = PREFIX_FOR_STORAGE_HEADER + "popreceipt";
582582

583+
/**
584+
* The header that specifies recursive listing.
585+
*/
586+
public static final String RECURSIVE = PREFIX_FOR_STORAGE_HEADER + "recursive";
587+
583588
/**
584589
* The header prefix for metadata.
585590
*/
@@ -715,7 +720,7 @@ public static class HeaderConstants {
715720
/**
716721
* Specifies the value to use for UserAgent header.
717722
*/
718-
public static final String USER_AGENT_VERSION = "8.2.0";
723+
public static final String USER_AGENT_VERSION = "8.3.0";
719724

720725
/**
721726
* The default type for content-type and accept
@@ -782,11 +787,21 @@ public static class QueryConstants {
782787
*/
783788
public static final String END_ROW_KEY = "erk";
784789

790+
/**
791+
* The query component for force close handles.
792+
*/
793+
public static final String CLOSE_HANDLES = "forceclosehandles";
794+
785795
/**
786796
* Query component value for list.
787797
*/
788798
public static final String LIST = "list";
789799

800+
/**
801+
* Query component for list handles.
802+
*/
803+
public static final String LIST_HANDLES = "listhandles";
804+
790805
/**
791806
* Query component value for properties.
792807
*/

microsoft-azure-storage/src/com/microsoft/azure/storage/ResultContinuationType.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,14 @@ public enum ResultContinuationType {
5252
* Specifies the token is a share listing continuation token.
5353
*/
5454
SHARE,
55+
56+
/**
57+
* Specifies the token is a handle listing continuation token.
58+
*/
59+
HANDLE,
60+
61+
/**
62+
* Specifies the token is a handle closing continuation token.
63+
*/
64+
HANDLE_CLOSE,
5565
}

microsoft-azure-storage/src/com/microsoft/azure/storage/blob/BlobInputStream.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,8 @@ protected BlobInputStream(long blobRangeOffset, Long blobRangeLength, final Clou
190190

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

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

198197
this.retrievedContentMD5Value = parentBlob.getProperties().getContentMD5();

0 commit comments

Comments
 (0)