Skip to content

Commit a460ee3

Browse files
Don't crash response if you can't log uri info
Happened in production a bit, fairly confident it was a scanner but don't know for sure becasue it doesn't print out the URI path! ``` e.s.l.e.s.utils.EnumExceptionMapper - Catching non user-facing IllegalArgumentException java.lang.IllegalArgumentException: Invalid URL encoding: not a valid digit (radix 16): 117" ```
1 parent 8fae2d2 commit a460ee3

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

proxyserver/src/main/java/edu/suffolk/litlab/efsp/server/utils/ObservabilityResetInterceptor.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,19 @@ public class ObservabilityResetInterceptor implements ContainerResponseFilter {
1919
@Override
2020
public void filter(ContainerRequestContext request, ContainerResponseContext response)
2121
throws IOException {
22-
log.info(
23-
"Sending back status of {} in response to {}",
24-
response.getStatus(),
25-
request.getUriInfo().getPath());
22+
var path = "";
23+
// Had issues where decoding a path would crash the whole response call.
24+
try {
25+
path = request.getUriInfo().getPath();
26+
} catch (IllegalArgumentException | IllegalStateException ex) {
27+
log.warn("No valid path to log?", ex);
28+
try {
29+
path = request.getUriInfo().getPath(false);
30+
} catch (IllegalArgumentException | IllegalStateException ex2) {
31+
path = "<dev note: could not get URI info>";
32+
}
33+
}
34+
log.info("Sending back status of {} in response to {}", response.getStatus(), path);
2635
MDCWrappers.removeAllMDCs();
2736
}
2837
}

0 commit comments

Comments
 (0)