Skip to content

Commit 11569d3

Browse files
committed
close request output stream
1 parent 2c643c3 commit 11569d3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.IOException;
1919
import java.io.InputStream;
20+
import java.io.OutputStream;
2021
import java.net.HttpURLConnection;
2122
import java.util.Date;
2223
import java.util.Map.Entry;
@@ -72,6 +73,7 @@ public static <CLIENT_TYPE, PARENT_TYPE, RESULT_TYPE> RESULT_TYPE executeWithRet
7273
int currentRetryCount = 0;
7374
StorageException translatedException = null;
7475
HttpURLConnection request = null;
76+
OutputStream requestOutputStream = null;
7577
final long startTime = new Date().getTime();
7678

7779
while (true) {
@@ -87,8 +89,9 @@ public static <CLIENT_TYPE, PARENT_TYPE, RESULT_TYPE> RESULT_TYPE executeWithRet
8789
try {
8890
if (task.getSendStream() != null) {
8991
Logger.info(opContext, LogConstants.UPLOAD);
92+
requestOutputStream = request.getOutputStream();
9093
final StreamMd5AndLength descriptor = Utility.writeToOutputStream(task.getSendStream(),
91-
request.getOutputStream(), task.getLength(), false /* rewindStream */,
94+
requestOutputStream, task.getLength(), false /* rewindStream */,
9295
false /* calculate MD5 */, opContext, task.getRequestOptions());
9396

9497
task.validateStreamWrite(descriptor);
@@ -131,6 +134,14 @@ public static <CLIENT_TYPE, PARENT_TYPE, RESULT_TYPE> RESULT_TYPE executeWithRet
131134

132135
ExecutionEngine.fireErrorReceivingResponseEvent(opContext, request, task.getResult());
133136
}
137+
if(requestOutputStream != null){
138+
if (requestOutputStream != null) {
139+
try {
140+
requestOutputStream.close();
141+
} catch (IOException logOrIgnore) {
142+
}
143+
}
144+
}
134145
}
135146

136147
// 8. Pre-process response to check if there was an exception. Do Response parsing (headers etc).

0 commit comments

Comments
 (0)