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

Commit 5cec298

Browse files
authored
Merge pull request #173 from jofriedm-msft/master
Java Storage Client Library 5.3.0
2 parents ca57847 + ac8c965 commit 5cec298

File tree

13 files changed

+130
-50
lines changed

13 files changed

+130
-50
lines changed

ChangeLog.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2017.06.13 Version 5.3.0
2+
* Fixed a bug where the transactional MD5 check would fail when downloading a range of blob or file and the recovery action is performed on a subsection of the range.
3+
* Fixed leaking connections for table requests.
4+
* Fixed a bug where retries happened immediately when experiencing a network exception uploading data or getting the response.
5+
* Fixed a bug where the response stream was not being closed on nonretryable exceptions.
6+
17
2017.05.23 Version 5.2.0
28
* Fixed Exists() calls on Shares and Directories to now populate metadata. This was already being done for Files.
39
* Changed blob constants to support up to 256 MB on put blob for block blobs. The default value for put blob threshold has also been updated to half of the maximum, or 128 MB currently.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To get the binaries of this library as distributed by Microsoft, ready for use w
3030
<dependency>
3131
<groupId>com.microsoft.azure</groupId>
3232
<artifactId>azure-storage</artifactId>
33-
<version>5.2.0</version>
33+
<version>5.3.0</version>
3434
</dependency>
3535
```
3636

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>5.2.0</version>
29+
<version>5.3.0</version>
3030
</dependency>
3131
<dependency>
3232
<groupId>com.microsoft.azure</groupId>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public static class HeaderConstants {
661661
/**
662662
* Specifies the value to use for UserAgent header.
663663
*/
664-
public static final String USER_AGENT_VERSION = "5.2.0";
664+
public static final String USER_AGENT_VERSION = "5.3.0";
665665

666666
/**
667667
* The default type for content-type and accept

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ public String getStatusMessage() {
173173
* @return A <code>java.util.Date</code> object which contains the stop date.
174174
*/
175175
public Date getStopDate() {
176+
if (this.stopDate == null)
177+
{
178+
// stop date was not initialized, most likely due to a network exception
179+
// if this is null, retries are immediate
180+
this.stopDate = new Date();
181+
}
182+
176183
return this.stopDate;
177184
}
178185

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void write(byte[] data, int offset, int length) throws IOException {
145145

146146
@Override
147147
public void write(InputStream sourceStream, long writeLength) throws IOException, StorageException {
148-
Utility.writeToOutputStream(sourceStream, this, writeLength, false, false, this.opContext, this.options, false);
148+
Utility.writeToOutputStream(sourceStream, this, writeLength, false, false, this.opContext, this.options, false);
149149
}
150150

151151
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ public Integer postProcessResponse(HttpURLConnection connection, CloudBlob blob,
14021402
// writeToOutputStream will update the currentRequestByteCount on this request in case a retry
14031403
// is needed and download should resume from that point
14041404
final StreamMd5AndLength descriptor = Utility.writeToOutputStream(streamRef, outStream, -1, false,
1405-
validateMD5, context, options, true, this);
1405+
validateMD5, context, options, true, this, this.getCurrentDescriptor());
14061406

14071407
// length was already checked by the NetworkInputStream, now check Md5
14081408
if (validateMD5 && !this.getContentMD5().equals(descriptor.getMd5())) {

microsoft-azure-storage/src/com/microsoft/azure/storage/core/Canonicalizer.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.util.List;
2626
import java.util.Map;
2727
import java.util.Map.Entry;
28+
import java.util.regex.Matcher;
29+
import java.util.regex.Pattern;
2830

2931
import com.microsoft.azure.storage.Constants;
3032
import com.microsoft.azure.storage.StorageException;
@@ -45,6 +47,8 @@ abstract class Canonicalizer {
4547
*/
4648
private static final int ExpectedTableCanonicalizedStringLength = 200;
4749

50+
private static final Pattern CRLF = Pattern.compile("\r\n", Pattern.LITERAL);
51+
4852
/**
4953
* Add x-ms- prefixed headers in a fixed order.
5054
*
@@ -85,7 +89,8 @@ private static void addCanonicalizedHeaders(final HttpURLConnection conn, final
8589
}
8690

8791
// Unfolding is simply removal of CRLF.
88-
final String unfoldedValue = value.replace("\r\n", Constants.EMPTY_STRING);
92+
final String unfoldedValue = CRLF.matcher(value)
93+
.replaceAll(Matcher.quoteReplacement(Constants.EMPTY_STRING));
8994

9095
// Append it to the canonicalized element string.
9196
canonicalizedElement.append(delimiter);
@@ -251,6 +256,11 @@ protected static String getCanonicalizedResource(final java.net.URL address, fin
251256
final StringBuilder canonicalizedResource = new StringBuilder(resourcepath.toString());
252257

253258
// query parameters
259+
if (address.getQuery() == null || !address.getQuery().contains("=")) {
260+
//no query params.
261+
return canonicalizedResource.toString();
262+
}
263+
254264
final Map<String, String[]> queryVariables = PathUtility.parseQueryString(address.getQuery());
255265

256266
final Map<String, String> lowercasedKeyNameValue = new HashMap<String, String>();

microsoft-azure-storage/src/com/microsoft/azure/storage/core/ExecutionEngine.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,10 @@ public static <CLIENT_TYPE, PARENT_TYPE, RESULT_TYPE> RESULT_TYPE executeWithRet
115115
currResult.setStartDate(new Date());
116116

117117
Logger.info(opContext, LogConstants.GET_RESPONSE);
118-
try {
119-
currResult.setStatusCode(request.getResponseCode());
120-
currResult.setStatusMessage(request.getResponseMessage());
121-
}
122-
finally {
123-
currResult.setStopDate(new Date());
124-
}
118+
119+
currResult.setStatusCode(request.getResponseCode());
120+
currResult.setStatusMessage(request.getResponseMessage());
121+
currResult.setStopDate(new Date());
125122

126123
currResult.setServiceRequestID(BaseResponse.getRequestId(request));
127124
currResult.setEtag(BaseResponse.getEtag(request));
@@ -168,6 +165,7 @@ public static <CLIENT_TYPE, PARENT_TYPE, RESULT_TYPE> RESULT_TYPE executeWithRet
168165
}
169166
}
170167
}
168+
171169
Logger.info(opContext, LogConstants.COMPLETE);
172170

173171
return result;

microsoft-azure-storage/src/com/microsoft/azure/storage/core/StorageRequest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public abstract class StorageRequest<C, P, R> {
9999
*/
100100
private String contentMD5 = null;
101101

102+
/**
103+
* Holds the descriptor which contains the stream length and MD5 hash.
104+
*/
105+
private StreamMd5AndLength currentDescriptor = null;
106+
102107
/**
103108
* Denotes the StorageUri of the request
104109
*/
@@ -212,6 +217,11 @@ public final String getContentMD5() {
212217
return this.contentMD5;
213218
}
214219

220+
/**
221+
* @return the current descriptor which contains the stream length and MD5 hash.
222+
*/
223+
protected StreamMd5AndLength getCurrentDescriptor() { return this.currentDescriptor; }
224+
215225
/**
216226
* @return the location mode used to decide which location the request should be sent to.
217227
*/
@@ -457,6 +467,14 @@ public void setContentMD5(String contentMD5) {
457467
this.contentMD5 = contentMD5;
458468
}
459469

470+
/**
471+
* @param currentDescriptor
472+
* the descriptor value
473+
*/
474+
protected void setCurrentDescriptor(StreamMd5AndLength currentDescriptor) {
475+
this.currentDescriptor = currentDescriptor;
476+
}
477+
460478
/**
461479
* @param etagLockCondition
462480
* the locked ETag condition

0 commit comments

Comments
 (0)