From 2430d5fe1de3f51641a6c76a157ca3a5be083893 Mon Sep 17 00:00:00 2001 From: Eric Mc Sween Date: Fri, 4 Dec 2020 11:05:47 -0500 Subject: [PATCH] Handle errors from the history service If the history service returns a non-success status code when we request a blob, chances are the payload is not the expected blob contents. We throw an exception in that case, which will abort the git operation. --- .../ac/ic/wlgitbridge/io/http/ning/NingHttpClient.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/io/http/ning/NingHttpClient.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/io/http/ning/NingHttpClient.java index 41c4bc73f3..e9d7f5f789 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/io/http/ning/NingHttpClient.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/io/http/ning/NingHttpClient.java @@ -52,11 +52,16 @@ public class NingHttpClient implements NingHttpClientFacade { @Override public byte[] onCompleted( Response response - ) throws IOException { + ) throws Exception { + int statusCode = response.getStatusCode(); + if (statusCode >= 400) { + throw new Exception("got status " + statusCode + + " fetching " + url); + } byte[] ret = bytes.toByteArray(); bytes.close(); log.info( - response.getStatusCode() + statusCode + " " + response.getStatusText() + " ("