diff --git a/src/main/java/io/cryostat/agent/harvest/Harvester.java b/src/main/java/io/cryostat/agent/harvest/Harvester.java index e4c04eef..280e6ec1 100644 --- a/src/main/java/io/cryostat/agent/harvest/Harvester.java +++ b/src/main/java/io/cryostat/agent/harvest/Harvester.java @@ -219,33 +219,28 @@ public void recordingStateChanged(Recording recording) { case STOPPED: try { tr.getRecording().dump(exitPaths.get(tr)); + uploadRecording(tr).get(); } catch (IOException e) { log.error("Failed to dump recording to file", e); + } catch (InterruptedException | ExecutionException e) { + log.warn("Could not upload exit dump file", e); } if (isSownRecording) { - recording.close(); + safeCloseCurrentRecording(); } // next break; case CLOSED: executor.submit( () -> { - if (isSownRecording) { - safeCloseCurrentRecording(); - } if (running) { try { Path exitPath = exitPaths.remove(tr); recordings.remove(tr); - uploadRecording(tr).get(); Files.deleteIfExists(exitPath); log.trace("Deleted temp file {}", exitPath); - } catch (ExecutionException - | InterruptedException - | IOException e) { - log.warn( - "Could not upload exit dump file", - e); + } catch (IOException e) { + log.warn("Could not delete temp file", e); } finally { startRecording(false); }