Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Commit

Permalink
Prevent BriefcaseException for trying to access a request's body when…
Browse files Browse the repository at this point in the history
… it's not present
  • Loading branch information
ggalmazor committed Oct 31, 2020
1 parent 8916aff commit 62f552b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/org/opendatakit/briefcase/reused/http/CommonsHttp.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private <T> Response<T> uncheckedExecute(Request<T> request, Executor executor)
} catch (IOException e) {
throw new UncheckedIOException(e);
} finally {
UncheckedFiles.closeInputStream(request.getBody());
request.ifBody(UncheckedFiles::closeInputStream);
if (request.multipartMessages != null)
request.multipartMessages.stream()
.map(MultipartMessage::getBody)
Expand Down
5 changes: 5 additions & 0 deletions src/org/opendatakit/briefcase/reused/http/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import org.opendatakit.briefcase.reused.BriefcaseException;
import org.slf4j.Logger;
Expand Down Expand Up @@ -124,6 +125,10 @@ public InputStream getBody() {
return body.orElseThrow(BriefcaseException::new);
}

public void ifBody(Consumer<InputStream> consumer) {
body.ifPresent(consumer);
}

public boolean ignoreCookies() {
return ignoreCookies;
}
Expand Down

0 comments on commit 62f552b

Please sign in to comment.