Skip to content

Commit

Permalink
InvalidEce
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg committed Sep 27, 2023
1 parent d899df2 commit 5021c0b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/io/cryostat/agent/remote/RecordingsContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,12 @@ private void handleStartRecordingOrSnapshot(HttpExchange exchange) throws IOExce
| ServiceNotAvailableException
| FlightRecorderException
| org.openjdk.jmc.rjmx.services.jfr.FlightRecorderException
| InvalidEventTemplateException
| InvalidXmlException
| IOException e) {
log.error("Failed to start recording", e);
exchange.sendResponseHeaders(HttpStatus.SC_INTERNAL_SERVER_ERROR, BODY_LENGTH_NONE);
} catch (InvalidEventTemplateException e) {
exchange.sendResponseHeaders(HttpStatus.SC_BAD_REQUEST, BODY_LENGTH_NONE);
}
}

Expand Down Expand Up @@ -421,7 +422,13 @@ private SerializableRecordingDescriptor startRecording(StartRecordingRequest req
localStorageTemplateService.addTemplate(
new ByteArrayInputStream(
req.template.getBytes(StandardCharsets.UTF_8)));
events = localStorageTemplateService.getEvents(template).orElseThrow();
events =
localStorageTemplateService
.getEvents(template)
.orElseThrow(
() ->
new InvalidEventTemplateException(
"Falied to retrieve recording events"));
cleanup =
() -> {
try {
Expand All @@ -435,7 +442,10 @@ private SerializableRecordingDescriptor startRecording(StartRecordingRequest req
new RemoteTemplateService(conn)
.getEvents(req.localTemplateName, TemplateType.TARGET).stream()
.findFirst()
.orElseThrow();
.orElseThrow(
() ->
new InvalidEventTemplateException(
"Failed to retrieve recording events"));
}
IFlightRecorderService svc = conn.getService();
return new SerializableRecordingDescriptor(
Expand Down

0 comments on commit 5021c0b

Please sign in to comment.