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

Commit a4d2cc4

Browse files
authored
Merge pull request #170 from jofriedm-msft/dev
Connection pooling fixes
2 parents 62d6e56 + 66edfbe commit a4d2cc4

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

ChangeLog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
2017.XX.XX Version X.X.X
22
* Fixed a bug where the tranactional 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.
36

47
2017.05.23 Version 5.2.0
58
* Fixed Exists() calls on Shares and Directories to now populate metadata. This was already being done for Files.

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/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/Utility.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,7 @@ public static JsonGenerator getJsonGenerator(OutputStream outStream) throws IOEx
657657
*/
658658
public static JsonParser getJsonParser(final String jsonString) throws JsonParseException, IOException {
659659
JsonParser parser = jsonFactory.createParser(jsonString);
660-
661-
// allows handling of infinity, -infinity, and NaN for Doubles
662-
return parser.enable(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS);
660+
return setupJsonParser(parser);
663661
}
664662

665663
/**
@@ -674,6 +672,20 @@ public static JsonParser getJsonParser(final String jsonString) throws JsonParse
674672
*/
675673
public static JsonParser getJsonParser(final InputStream inStream) throws JsonParseException, IOException {
676674
JsonParser parser = jsonFactory.createParser(inStream);
675+
return setupJsonParser(parser);
676+
}
677+
678+
/**
679+
* Returns a <code>JsonParser</code> This JsonParser will allow non-numeric numbers.
680+
* @param parser
681+
* A <code>JsonParser</code> to setup.
682+
* @return
683+
* A <code>JsonParser</code> with settings configured.
684+
*/
685+
private static JsonParser setupJsonParser(final JsonParser parser) {
686+
// IMPORTANT: DO NOT REMOVE!
687+
// don't close the stream and allow it to be drained completely in ExecutionEngine to improve socket reuse
688+
parser.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
677689

678690
// allows handling of infinity, -infinity, and NaN for Doubles
679691
return parser.enable(JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS);

0 commit comments

Comments
 (0)