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

Commit cec23f4

Browse files
authored
Merge pull request #459 from Azure/dev
Dev
2 parents 12d9633 + 60b1ec0 commit cec23f4

File tree

83 files changed

+3871
-723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+3871
-723
lines changed

BreakingChanges.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
2018.08.11 Version 10.1.0
1+
XXXX.XX.XX Version XX.X.X
2+
* Upgraded to version 2.1.0 of the autorest-clientruntime which includes several important fixes to mitigate a commonly-seen "Connection reset by peer" error and other similar bugs.
3+
* HTTPGetterInfo was made an internal type as it is an internal implementation detail.
4+
* Added SourceModifiedAccessConditions parameter to StageBlockFromURL
5+
* Removed DEFAULT and NONE static variables. Empty constructors should be used instead. DEFAULT static values were error prone and unsafe to use because although the field was final, the objects were mutable, so it was possible the value could be changed accidentally and alter the behavior of the program.
6+
* Changed *ListingDetails to *ListDetails. These name changes are to mitigate conflicts with v8, allowing for side-by-side loading of different versions, which may help with upgrading.
7+
* Removed the extra quotes around etags in some responses so they are consistently now consistently formatted.
8+
* Moved the Generated*** types into the blob package to avoid conflicts with generated types from other services (i.e. queues and files)
9+
* Changed the logger name to be the name of class that uses it, which is a more conventional practice
10+
* Made the max results field on listing responses Integer instead of int as it is an optional field only returned when specified in the request.
11+
12+
2018.08.11 Version 10.1.0
213
* Interfaces for helper types updated to be more consistent throughout the library. All types, with the exception of the options for pipeline factories, use a fluent pattern.
314
* Removed RetryReader type as it's functionality was moved to be built into the DownloadResponse. RetryReaderOptions are now named ReliableDownloadOptions.
415
* Restructured the access conditions to be more logically adhere to their respective functions.
516
* Added support for context parameter on each api to allow communication with the pipeline from the application level
17+
* Added an option to configure that maximum size data that will be uploaded in a single shot via the TransferManager.
618

719
2018.08.22 Version 10.0.4-rc
820
* Changed BlobURL.startCopy sourceAccessConditions parameter to be HTTPAccessConditions as lease is not actually supported.

ChangeLog.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2019.03.22 Version 11.0.0
2+
* Upgraded to version 2.1.0 of the autorest-clientruntime which includes several important fixes to mitigate a commonly-seen "Connection reset by peer" error and other similar bugs.
3+
* Support for 2018-11-09 REST version. Please see our REST API documentation and blogs for information about the related added features.
4+
* Added appendBlockFromURL method. A block may be created with another blob as its source.
5+
* Added uploadPagesFromURL method. Pages may be written to with another blob as their source.
6+
* Fixed a bug that would set an invalid range header when downloading an empty blob.
7+
* Modified the LoggingFactory to redact SAS signatures on outgoing requests.
8+
* HTTPGetterInfo was made an internal type as it is an internal implementation detail.
9+
* Removed DEFAULT and NONE static variables. Empty constructors should be used instead. DEFAULT static values were error prone and unsafe to use because although the field was final, the objects were mutable, so it was possible the value could be changed accidentally and alter the behavior of the program.
10+
* Optimized the TransferManager download to file method to skip the initial HEAD request.
11+
* Added an option to configure that maximum size data that will be uploaded in a single shot via the TransferManager.
12+
* Added request Http Method, URL, and headers to logging messages.
13+
* Changed *ListingDetails to *ListDetails. These name changes are to mitigate conflicts with v8, allowing for side-by-side loading of different versions, which may help with upgrading.
14+
* Removed the extra quotes around etags in some responses so they are consistently now consistently formatted.
15+
* Moved the Generated*** types into the blob package to avoid conflicts with generated types from other services (i.e. queues and files)
16+
* Changed the logger name to be the name of class that uses it, which is a more conventional practice
17+
* Support added for SAS tokens to scope to blob snapshot.
18+
* Added getUserDelegationKey to ServiceURL, the result of which can be used to generate a user-delegation SAS.
19+
* Made the max results field on listing responses Integer instead of int as it is an optional field only returned when specified in the request.
20+
121
2019.02.15 Version 10.5.0
222
* Added uploadFromNonReplayableFlowable to support uploading arbitrary data sources (like network streams) to a block blob.
323

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
3737
<dependency>
3838
<groupId>com.microsoft.azure</groupId>
3939
<artifactId>azure-storage-blob</artifactId>
40-
<version>10.5.0</version>
40+
<version>11.0.0</version>
4141
</dependency>
4242
```
4343

pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<groupId>com.microsoft.azure</groupId>
1616
<artifactId>azure-storage-blob</artifactId>
17-
<version>10.5.0</version>
17+
<version>11.0.0</version>
1818

1919
<name>Azure Storage Blob</name>
2020
<description>The Azure Storage Java Blob library.</description>
@@ -65,13 +65,19 @@
6565
<dependency>
6666
<groupId>com.microsoft.rest.v2</groupId>
6767
<artifactId>client-runtime</artifactId>
68-
<version>2.0.2</version>
68+
<version>2.1.0</version>
6969
</dependency>
7070
<dependency>
7171
<groupId>org.slf4j</groupId>
7272
<artifactId>slf4j-api</artifactId>
7373
<version>1.7.25</version>
7474
</dependency>
75+
<dependency>
76+
<groupId>com.microsoft.azure</groupId>
77+
<artifactId>adal4j</artifactId>
78+
<version>1.6.3</version>
79+
<scope>test</scope>
80+
</dependency>
7581
<dependency>
7682
<groupId>junit</groupId>
7783
<artifactId>junit</artifactId>

src/main/java/com/microsoft/azure/storage/blob/AccountSASSignatureValues.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public SASQueryParameters generateSASQueryParameters(SharedKeyCredentials shared
217217

218218
return new SASQueryParameters(this.version, this.services, resourceTypes,
219219
this.protocol, this.startTime, this.expiryTime, this.ipRange, null,
220-
null, this.permissions, signature, null, null, null, null, null);
220+
null, this.permissions, signature, null, null, null, null, null, null);
221221
}
222222

223223
private String stringToSign(final SharedKeyCredentials sharedKeyCredentials) {
@@ -228,7 +228,7 @@ private String stringToSign(final SharedKeyCredentials sharedKeyCredentials) {
228228
resourceTypes,
229229
this.startTime == null ? "" : Utility.ISO8601UTCDateFormatter.format(this.startTime),
230230
Utility.ISO8601UTCDateFormatter.format(this.expiryTime),
231-
this.ipRange == null ? IPRange.DEFAULT.toString() : this.ipRange.toString(),
231+
this.ipRange == null ? (new IPRange()).toString() : this.ipRange.toString(),
232232
this.protocol == null ? "" : this.protocol.toString(),
233233
this.version,
234234
Constants.EMPTY_STRING // Account SAS requires an additional newline character

src/main/java/com/microsoft/azure/storage/blob/AppendBlobAccessConditions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
*/
2929
public final class AppendBlobAccessConditions {
3030

31-
/**
32-
* An object representing no access conditions.
33-
*/
34-
public static final AppendBlobAccessConditions NONE =
35-
new AppendBlobAccessConditions();
36-
3731
private AppendPositionAccessConditions appendPositionAccessConditions;
3832

3933
private ModifiedAccessConditions modifiedAccessConditions;

src/main/java/com/microsoft/azure/storage/blob/AppendBlobURL.java

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
*/
1515
package com.microsoft.azure.storage.blob;
1616

17-
import com.microsoft.azure.storage.blob.models.AppendBlobAppendBlockResponse;
18-
import com.microsoft.azure.storage.blob.models.AppendBlobCreateResponse;
19-
import com.microsoft.azure.storage.blob.models.BlobHTTPHeaders;
17+
import com.microsoft.azure.storage.blob.models.*;
2018
import com.microsoft.rest.v2.Context;
2119
import com.microsoft.rest.v2.http.HttpPipeline;
2220
import io.reactivex.Flowable;
@@ -27,7 +25,7 @@
2725
import java.net.UnknownHostException;
2826
import java.nio.ByteBuffer;
2927

30-
import static com.microsoft.azure.storage.blob.Utility.addErrorWrappingToSingle;
28+
import static com.microsoft.azure.storage.blob.Utility.postProcessResponse;
3129

3230

3331
/**
@@ -132,11 +130,11 @@ public Single<AppendBlobCreateResponse> create() {
132130
*/
133131
public Single<AppendBlobCreateResponse> create(BlobHTTPHeaders headers, Metadata metadata,
134132
BlobAccessConditions accessConditions, Context context) {
135-
metadata = metadata == null ? Metadata.NONE : metadata;
136-
accessConditions = accessConditions == null ? BlobAccessConditions.NONE : accessConditions;
133+
metadata = metadata == null ? new Metadata() : metadata;
134+
accessConditions = accessConditions == null ? new BlobAccessConditions() : accessConditions;
137135
context = context == null ? Context.NONE : context;
138136

139-
return addErrorWrappingToSingle(this.storageClient.generatedAppendBlobs().createWithRestResponseAsync(context,
137+
return postProcessResponse(this.storageClient.generatedAppendBlobs().createWithRestResponseAsync(context,
140138
0, null, metadata, null, headers, accessConditions.leaseAccessConditions(),
141139
accessConditions.modifiedAccessConditions()));
142140
}
@@ -195,15 +193,88 @@ public Single<AppendBlobAppendBlockResponse> appendBlock(Flowable<ByteBuffer> da
195193
*/
196194
public Single<AppendBlobAppendBlockResponse> appendBlock(Flowable<ByteBuffer> data, long length,
197195
AppendBlobAccessConditions appendBlobAccessConditions, Context context) {
198-
appendBlobAccessConditions = appendBlobAccessConditions == null ? AppendBlobAccessConditions.NONE :
196+
appendBlobAccessConditions = appendBlobAccessConditions == null ? new AppendBlobAccessConditions() :
199197
appendBlobAccessConditions;
200198
appendBlobAccessConditions = appendBlobAccessConditions == null
201-
? AppendBlobAccessConditions.NONE : appendBlobAccessConditions;
199+
? new AppendBlobAccessConditions() : appendBlobAccessConditions;
202200
context = context == null ? Context.NONE : context;
203201

204-
return addErrorWrappingToSingle(this.storageClient.generatedAppendBlobs().appendBlockWithRestResponseAsync(
202+
return postProcessResponse(this.storageClient.generatedAppendBlobs().appendBlockWithRestResponseAsync(
205203
context, data, length, null, null, null, appendBlobAccessConditions.leaseAccessConditions(),
206204
appendBlobAccessConditions.appendPositionAccessConditions(),
207205
appendBlobAccessConditions.modifiedAccessConditions()));
208206
}
207+
208+
/**
209+
* Commits a new block of data from another blob to the end of this append blob. For more information, see the
210+
* <a href="https://docs.microsoft.com/rest/api/storageservices/append-block">Azure Docs</a>.
211+
* <p>
212+
*
213+
* @param sourceURL
214+
* The url to the blob that will be the source of the copy. A source blob in the same storage account can
215+
* be authenticated via Shared Key. However, if the source is a blob in another account, the source blob
216+
* must either be public or must be authenticated via a shared access signature. If the source blob is
217+
* public, no authentication is required to perform the operation.
218+
* @param sourceRange
219+
* The source {@link BlobRange} to copy.
220+
*
221+
* @return Emits the successful response.
222+
*
223+
* @apiNote ## Sample Code \n
224+
* [!code-java[Sample_Code](../azure-storage-java/src/test/java/com/microsoft/azure/storage/Samples.java?name=append_from_url "Sample code for AppendBlobURL.appendBlockFromUrl")]
225+
* For more samples, please see the [Samples file](%https://github.com/Azure/azure-storage-java/blob/master/src/test/java/com/microsoft/azure/storage/Samples.java)
226+
*/
227+
public Single<AppendBlobAppendBlockFromUrlResponse> appendBlockFromUrl(URL sourceURL, BlobRange sourceRange) {
228+
return this.appendBlockFromUrl(sourceURL, sourceRange, null, null,
229+
null, null);
230+
}
231+
232+
/**
233+
* Commits a new block of data from another blob to the end of this append blob. For more information, see the
234+
* <a href="https://docs.microsoft.com/rest/api/storageservices/append-block">Azure Docs</a>.
235+
* <p>
236+
*
237+
* @param sourceURL
238+
* The url to the blob that will be the source of the copy. A source blob in the same storage account can
239+
* be authenticated via Shared Key. However, if the source is a blob in another account, the source blob
240+
* must either be public or must be authenticated via a shared access signature. If the source blob is
241+
* public, no authentication is required to perform the operation.
242+
* @param sourceRange
243+
* {@link BlobRange}
244+
* @param sourceContentMD5
245+
* An MD5 hash of the block content from the source blob. If specified, the service will calculate the MD5
246+
* of the received data and fail the request if it does not match the provided MD5.
247+
* @param destAccessConditions
248+
* {@link AppendBlobAccessConditions}
249+
* @param sourceAccessConditions
250+
* {@link SourceModifiedAccessConditions}
251+
* @param context
252+
* {@code Context} offers a means of passing arbitrary data (key/value pairs) to an
253+
* {@link com.microsoft.rest.v2.http.HttpPipeline}'s policy objects. Most applications do not need to pass
254+
* arbitrary data to the pipeline and can pass {@code Context.NONE} or {@code null}. Each context object is
255+
* immutable. The {@code withContext} with data method creates a new {@code Context} object that refers to
256+
* its parent, forming a linked list.
257+
*
258+
* @return Emits the successful response.
259+
*
260+
* @apiNote ## Sample Code \n
261+
* [!code-java[Sample_Code](../azure-storage-java/src/test/java/com/microsoft/azure/storage/Samples.java?name=append_from_url "Sample code for AppendBlobURL.appendBlockFromUrl")]
262+
* For more samples, please see the [Samples file](%https://github.com/Azure/azure-storage-java/blob/master/src/test/java/com/microsoft/azure/storage/Samples.java)
263+
*/
264+
public Single<AppendBlobAppendBlockFromUrlResponse> appendBlockFromUrl(URL sourceURL, BlobRange sourceRange,
265+
byte[] sourceContentMD5, AppendBlobAccessConditions destAccessConditions,
266+
SourceModifiedAccessConditions sourceAccessConditions, Context context) {
267+
268+
sourceRange = sourceRange == null ? new BlobRange() : sourceRange;
269+
destAccessConditions = destAccessConditions == null
270+
? new AppendBlobAccessConditions() : destAccessConditions;
271+
context = context == null ? Context.NONE : context;
272+
273+
return postProcessResponse(
274+
this.storageClient.generatedAppendBlobs().appendBlockFromUrlWithRestResponseAsync(context,
275+
sourceURL, 0, sourceRange.toString(), sourceContentMD5, null, null,
276+
destAccessConditions.leaseAccessConditions(),
277+
destAccessConditions.appendPositionAccessConditions(),
278+
destAccessConditions.modifiedAccessConditions(), sourceAccessConditions));
279+
}
209280
}

src/main/java/com/microsoft/azure/storage/blob/BlobAccessConditions.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
*/
2626
public final class BlobAccessConditions {
2727

28-
public static final BlobAccessConditions NONE =
29-
new BlobAccessConditions();
30-
3128
private ModifiedAccessConditions modifiedAccessConditions;
3229

3330
private LeaseAccessConditions leaseAccessConditions;

src/main/java/com/microsoft/azure/storage/blob/BlobListingDetails.java renamed to src/main/java/com/microsoft/azure/storage/blob/BlobListDetails.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
* changing the details for a different listing operation requires construction of a new object. Null may be passed if
2525
* none of the options are desirable.
2626
*/
27-
public final class BlobListingDetails {
28-
29-
/**
30-
* An object representing no listing details.
31-
*/
32-
public static final BlobListingDetails NONE = new BlobListingDetails();
27+
public final class BlobListDetails {
3328

3429
private boolean copy;
3530

@@ -41,7 +36,7 @@ public final class BlobListingDetails {
4136

4237
private boolean deletedBlobs;
4338

44-
public BlobListingDetails() {
39+
public BlobListDetails() {
4540
}
4641

4742
/**
@@ -56,7 +51,7 @@ public boolean copy() {
5651
* Whether blob metadata related to any current or previous Copy Blob operation should be included in the
5752
* response.
5853
*/
59-
public BlobListingDetails withCopy(boolean copy) {
54+
public BlobListDetails withCopy(boolean copy) {
6055
this.copy = copy;
6156
return this;
6257
}
@@ -71,7 +66,7 @@ public boolean metadata() {
7166
/**
7267
* Whether blob metadata should be returned.
7368
*/
74-
public BlobListingDetails withMetadata(boolean metadata) {
69+
public BlobListDetails withMetadata(boolean metadata) {
7570
this.metadata = metadata;
7671
return this;
7772
}
@@ -86,7 +81,7 @@ public boolean snapshots() {
8681
/**
8782
* Whether snapshots should be returned. Snapshots are listed from oldest to newest.
8883
*/
89-
public BlobListingDetails withSnapshots(boolean snapshots) {
84+
public BlobListDetails withSnapshots(boolean snapshots) {
9085
this.snapshots = snapshots;
9186
return this;
9287
}
@@ -103,7 +98,7 @@ public boolean uncommittedBlobs() {
10398
* Whether blobs for which blocks have been uploaded, but which have not been committed using Put Block List,
10499
* should be included in the response.
105100
*/
106-
public BlobListingDetails withUncommittedBlobs(boolean uncommittedBlobs) {
101+
public BlobListDetails withUncommittedBlobs(boolean uncommittedBlobs) {
107102
this.uncommittedBlobs = uncommittedBlobs;
108103
return this;
109104
}
@@ -118,7 +113,7 @@ public boolean deletedBlobs() {
118113
/**
119114
* Whether blobs which have been soft deleted should be returned.
120115
*/
121-
public BlobListingDetails withDeletedBlobs(boolean deletedBlobs) {
116+
public BlobListDetails withDeletedBlobs(boolean deletedBlobs) {
122117
this.deletedBlobs = deletedBlobs;
123118
return this;
124119
}

src/main/java/com/microsoft/azure/storage/blob/BlobRange.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
*/
2424
public final class BlobRange {
2525

26-
/**
27-
* An object which reflects the service's default range, which is the whole blob.
28-
*/
29-
public static final BlobRange DEFAULT = new BlobRange();
30-
3126
private long offset;
3227

3328
private Long count;
@@ -86,4 +81,17 @@ public String toString() {
8681
return String.format(
8782
Locale.ROOT, Constants.HeaderConstants.BEGIN_RANGE_HEADER_FORMAT, this.offset);
8883
}
84+
85+
/*
86+
In the case where the customer passes a null BlobRange, constructing the default of "0-" will fail on an empty blob.
87+
By returning null as the header value, we elect not to set the header, which has the same effect, namely downloading
88+
the whole blob, but it will not fail in the empty case.
89+
*/
90+
String toHeaderValue() {
91+
// The default values of a BlobRange
92+
if (this.offset == 0 && this.count == null) {
93+
return null;
94+
}
95+
return this.toString();
96+
}
8997
}

0 commit comments

Comments
 (0)