Skip to content
Merged

PR Fixes #22276

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ It is typically a bad idea to lock around customer code (which the progressRecei
requests happening at once to stage/download separate chunks, so we still need to lock either way.
*/
transferLock.lock();
progressReceiver.reportProgress(totalProgress.addAndGet(bytesTransferred));
transferLock.unlock();
try {
progressReceiver.reportProgress(totalProgress.addAndGet(bytesTransferred));
} finally {
transferLock.unlock();
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import static org.hamcrest.CoreMatchers.equalTo;
Expand All @@ -27,14 +28,14 @@ public class DownloadContentLiveTests extends CallingServerTestBase {

@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void downloadMetadata(HttpClient httpClient) {
public void downloadMetadata(HttpClient httpClient) throws UnsupportedEncodingException {
CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient);
CallingServerClient conversationClient = setupClient(builder, "downloadMetadata");

try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
conversationClient.downloadTo(METADATA_URL, byteArrayOutputStream, null);
String metadata = byteArrayOutputStream.toString(StandardCharsets.UTF_8);
String metadata = byteArrayOutputStream.toString(StandardCharsets.UTF_8.name());
assertThat(metadata.contains("0-eus-d2-3cca2175891f21c6c9a5975a12c0141c"), is(true));
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
Expand Down