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


##########
tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojo.java:
##########
@@ -117,6 +117,8 @@ private JsonArray processOldReleases() throws Exception {
         return Jsoner.deserialize(json, new JsonArray());
     }
 
+    // HttpClient does not implement AutoCloseable before Java 21; short-lived 
and GC'd
+    @SuppressWarnings("java:S2095")
     private List<ReleaseModel> processReleases(List<String> urls) throws 
Exception {
         List<ReleaseModel> answer = new ArrayList<>();
 

Review Comment:
   Method-level @SuppressWarnings("java:S2095") is broad enough to also 
suppress real resource-leak findings inside this method (e.g., the 
LineNumberReader created later in the loop). To avoid hiding legitimate S2095 
warnings, scope the suppression to the HttpClient local variable instead of the 
entire method, and update the comment to avoid implying GC-based cleanup.



##########
tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/UpdateCamelReleasesMojo.java:
##########
@@ -158,6 +160,8 @@ private List<ReleaseModel> processReleases(List<String> 
urls) throws Exception {
         return answer;
     }
 
+    // HttpClient does not implement AutoCloseable before Java 21; short-lived 
and GC'd
+    @SuppressWarnings("java:S2095")
     private List<String> fetchCamelReleaseLinks(String gitUrl) throws 
Exception {
         List<String> answer = new ArrayList<>();
 

Review Comment:
   The method-level S2095 suppression is broader than necessary and the 
comment's “GC'd” rationale is misleading (there is no explicit close action for 
HttpClient on JDK 17). Prefer scoping the suppression to the HttpClient local 
variable and keep the comment focused on the JDK/AutoCloseable mismatch.



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ShellPanel.java:
##########
@@ -391,6 +391,8 @@ static Line convertRow(long[] buffer, int offset, int 
width) {
 
     private String startError;
 
+    // DelegateOutputStream and feedbackOutput are owned by the 
virtualTerminal; closed in stopShell()
+    @SuppressWarnings("java:S2095")
     private void startShell(int width, int height) {

Review Comment:
   The comment says DelegateOutputStream/feedbackOutput are “closed in 
stopShell()”, but stopShell() directly closes only virtualTerminal. To keep the 
justification verifiably accurate, reference the virtualTerminal 
ownership/closure rather than specific underlying streams.



##########
test-infra/camel-test-infra-qdrant/src/main/java/org/apache/camel/test/infra/qdrant/services/QdrantInfraService.java:
##########
@@ -52,6 +52,8 @@ default String apiKey() {
         return "";
     }
 
+    // HttpClient does not implement AutoCloseable before Java 21; short-lived 
and GC'd
+    @SuppressWarnings("java:S2095")
     default HttpResponse<byte[]> put(String path, Map<Object, Object> body) 
throws Exception {

Review Comment:
   The comment mentions the client being “GC'd”, but garbage collection is not 
a reliable/meaningful resource-management mechanism here; the core point is 
that HttpClient is not AutoCloseable on the project’s target JDK so there is 
nothing to close. Consider rewording to avoid suggesting GC-based cleanup.



-- 
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