From 4ef597efde31b919757e4c72c728c1b1d61eeacb Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Thu, 28 Mar 2024 16:29:02 -0400 Subject: [PATCH] avoid NoResultException if 'archive on stop' recording is already deleted. may still occur in a race condition, but is harmless - just log noise --- .../java/io/cryostat/recordings/RecordingHelper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/cryostat/recordings/RecordingHelper.java b/src/main/java/io/cryostat/recordings/RecordingHelper.java index 6ea1058ee..8794d9444 100644 --- a/src/main/java/io/cryostat/recordings/RecordingHelper.java +++ b/src/main/java/io/cryostat/recordings/RecordingHelper.java @@ -1101,10 +1101,13 @@ static class StopRecordingJob implements Job { public void execute(JobExecutionContext ctx) throws JobExecutionException { var jobDataMap = ctx.getJobDetail().getJobDataMap(); try { - ActiveRecording recording = + Optional recording = ActiveRecording.find("id", (Long) jobDataMap.get("recordingId")) - .singleResult(); - recordingHelper.stopRecording(recording, (Boolean) jobDataMap.get("archive")); + .singleResultOptional(); + if (recording.isPresent()) { + recordingHelper.stopRecording( + recording.get(), (Boolean) jobDataMap.get("archive")); + } } catch (Exception e) { throw new JobExecutionException(e); }