Copilot commented on code in PR #24491:
URL: https://github.com/apache/camel/pull/24491#discussion_r3536360270


##########
core/camel-console/src/main/java/org/apache/camel/impl/console/JfrMemoryLeakDevConsole.java:
##########
@@ -165,6 +165,7 @@ private synchronized JsonObject doStart(Map<String, Object> 
options) {
             }
             return result;
         } catch (Exception e) {
+            rec.close();
             LOG.warn("Failed to start JFR recording: {}", e.getMessage(), e);
             return errorJson("Failed to start JFR recording: " + 
e.getMessage());
         }

Review Comment:
   If an exception is thrown after `activeRecording = rec` (e.g., while 
scheduling the auto-stop task), the catch block closes the recording but leaves 
`activeRecording` pointing at a closed `Recording`. That can make subsequent 
`status/stop/start` calls behave incorrectly (e.g., attempts to stop a closed 
recording, or being blocked from starting a new one). The catch block should 
clear `activeRecording` (when it matches `rec`) and cancel any scheduled 
auto-stop, and it should ensure that `rec.close()` cannot mask the original 
exception path.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to