Skip to content

Commit

Permalink
Fix RemoteFileSupplier (#3683)
Browse files Browse the repository at this point in the history
  • Loading branch information
CTMBNara authored Jan 23, 2025
1 parent e61ada5 commit 89d68f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private Future<Boolean> isSizeChanged() {
private Future<Void> downloadFile() {
return fileSystem.open(tmpPath, new OpenOptions())
.compose(tmpFile -> sendHttpRequest(getRequestOptions)
.compose(response -> response.pipeTo(tmpFile))
.onComplete(result -> tmpFile.close()));
.onFailure(ignored -> tmpFile.close())
.compose(response -> response.pipeTo(tmpFile)));
}

private Future<HttpClientResponse> sendHttpRequest(RequestOptions requestOptions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void getShouldReturnFailureOnNotOkStatusCode() {
final Future<String> result = target.get();

// then
verify(tmpFile).close();
FutureAssertion.assertThat(result).isFailed()
.hasMessage("Got unexpected response from server with status code 204 and message null");
}
Expand All @@ -147,7 +148,6 @@ public void getShouldReturnExpectedResult() {
final Future<String> result = target.get();

// then
verify(tmpFile).close();
assertThat(result.result()).isEqualTo(SAVE_PATH);
}

Expand Down Expand Up @@ -178,7 +178,6 @@ public void getShouldReturnExpectedResultWhenCheckRemoteFileSizeIsTrue() {
final Future<String> result = target.get();

// then
verify(tmpFile).close();
assertThat(result.result()).isEqualTo(SAVE_PATH);
}

Expand Down

0 comments on commit 89d68f2

Please sign in to comment.