Skip to content

Commit e3b1ee6

Browse files
committed
Improve nested error handling in retrieval of TAP error documents.
Ensure that errors in both the initial retrieval and in the retrieval of a redirected error document are handled correctly. Previous version was incorrectly still reporting an error after a successful redirect.
1 parent 46f4f27 commit e3b1ee6

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

docs/release-notes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
- Fixed: mouse wheel / trackpad scrolling performance issue ([Firefly-793](https://github.com/Caltech-IPAC/firefly/pull/1098))
4242
- Fixed: Handle redirects when retrieving TAP errors ([DM-30073](https://github.com/Caltech-IPAC/firefly/pull/1092))
4343
- Fixed: problem is misusing the referer header
44+
- 2021.2.X
45+
- Fixed: initialization of userInfo object
46+
- Fixed: further refinement to error handling when retrieving TAP error documents
4447

4548

4649
##### _Pull Request in this release_

src/firefly/java/edu/caltech/ipac/firefly/server/query/AsyncTapQuery.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public AsyncJob submitRequest(ServerRequest request) throws DataAccessException
5252
if (maxrec > -1) { inputs.setParam("MAXREC", Integer.toString(maxrec)); }
5353
inputs.setParam("LANG", lang); // in tap 1.0, lang param is required
5454
inputs.setParam("request", "doQuery"); // in tap 1.0, request param is required
55-
55+
5656
AsyncTapJob asyncTap = new AsyncTapJob();
5757
HttpServices.postData(inputs, (method -> {
5858
String location = HttpServices.getResHeader(method, "Location", null);
@@ -64,7 +64,7 @@ public AsyncJob submitRequest(ServerRequest request) throws DataAccessException
6464
asyncTap.setErrorMsg("Failed to submit async job to " + serviceUrl);
6565
}
6666
}));
67-
67+
6868
if (asyncTap.getPhase() == AsyncJob.Phase.PENDING) {
6969
HttpServices.postData(HttpServiceInput.createWithCredential(asyncTap.baseJobUrl + "/phase").setParam("PHASE", "RUN"));
7070
}
@@ -107,7 +107,7 @@ private static String getErrResp(HttpMethod method, String errorUrl) {
107107
} catch (DataAccessException e) {
108108
errMsg = e.getMessage();
109109
} catch (Exception e) {
110-
errMsg = "Unable to get error from " + errorUrl;
110+
errMsg = "Unknown error retrieving error document from "+errorUrl;
111111
}
112112
return errMsg;
113113
}
@@ -208,19 +208,21 @@ public String getErrorMsg() {
208208
} else if (HttpServices.isRedirected(method)) {
209209
String location = HttpServices.getResHeader(method, "Location", null);
210210
if (location != null) {
211-
HttpServices.getData(HttpServiceInput.createWithCredential(location),
211+
HttpServices.Status redirectStatus = HttpServices.getData(HttpServiceInput.createWithCredential(location),
212212
(redirectMethod -> err.setSource(getErrResp(redirectMethod, errorUrl))));
213+
if (redirectStatus.isError()) {
214+
err.setSource("Error retrieving redirected error document from "+location+": "+redirectStatus.getErrMsg());
215+
}
213216
} else {
214-
throw new RuntimeException("Request redirected without a location header");
217+
throw new RuntimeException("Error document request redirected without a location header");
215218
}
219+
} else {
220+
err.setSource("Error retrieving error document from "+errorUrl+": "+method.getStatusText());
216221
}
217222
} catch (Exception e) {
218223
throw new RuntimeException(e.getMessage());
219224
}
220225
}));
221-
if (status.isError()) {
222-
return "Unable to get error from "+errorUrl+" "+status.getErrMsg();
223-
}
224226
return err.getSource();
225227
}
226228

@@ -248,14 +250,3 @@ private String getFilename(String urlStr) {
248250

249251
}
250252
}
251-
252-
253-
254-
255-
256-
257-
258-
259-
260-
261-

0 commit comments

Comments
 (0)