Skip to content

Commit

Permalink
avail: fix handling of IllegalArgumentException from setState
Browse files Browse the repository at this point in the history
  • Loading branch information
pdowler committed Sep 19, 2024
1 parent 31359c5 commit 3f54c60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cadc-vosi/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sourceCompatibility = 1.8

group = 'org.opencadc'

version = '1.4.7'
version = '1.4.8'

description = 'OpenCADC VOSI server library'
def git_url = 'https://github.com/opencadc/reg'
Expand Down
10 changes: 10 additions & 0 deletions cadc-vosi/src/main/java/ca/nrc/cadc/vosi/AvailabilityServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import ca.nrc.cadc.util.PropertiesReader;
import ca.nrc.cadc.util.StringUtil;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.security.Principal;
import java.util.HashSet;
Expand Down Expand Up @@ -202,6 +203,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
String caller = im.toDisplayString(subject);
if (authorized(subject)) {
String state = request.getParameter("state");
log.warn("state=" + state + " by " + caller);
ap.setState(state);
log.info("WebService state change by " + caller + " [OK]");
} else {
Expand All @@ -211,6 +213,14 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
response.sendRedirect(request.getRequestURL().toString());

logInfo.setSuccess(true);
} catch (IllegalArgumentException ex) {
response.setStatus(400);
response.setHeader("content-type", "text/plain");
PrintWriter w = response.getWriter();
w.println(ex.getMessage());
w.close();
logInfo.setSuccess(true);
logInfo.setMessage(ex.toString());
} catch (Throwable t) {
log.error("BUG", t);
response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, t.getMessage());
Expand Down

0 comments on commit 3f54c60

Please sign in to comment.