You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/04/23 10:58:05 UTC

[GitHub] [kafka] tombentley commented on a change in pull request #8449: KAFKA-7613: Enable -Xlint:try, fixing warnings

tombentley commented on a change in pull request #8449:
URL: https://github.com/apache/kafka/pull/8449#discussion_r413718361



##########
File path: clients/src/main/java/org/apache/kafka/server/policy/AlterConfigPolicy.java
##########
@@ -32,6 +32,7 @@
  * using the default constructor and will then pass the broker configs to its <code>configure()</code> method. During
  * broker shutdown, the <code>close()</code> method will be invoked so that resources can be released (if necessary).
  */
+@SuppressWarnings("try") // can't override close() to now declare throws Exception until Kafka 3.0

Review comment:
       Sorry the comment isn't too helpful. The problem is that `AlterConfigPolicy` inherits `close() from `AutoCloseable` which declares it to throw `Exception`, which includes `InterruptedException`, which generates the warning. 
   
   /home/tom/messaging/kafka/clients/src/main/java/org/apache/kafka/server/policy/AlterConfigPolicy.java:35: warning: [try] auto-closeable resource AlterConfigPolicy has a member method close() that could throw InterruptedException
   
   So one solution would be to enumerate more specific checked exceptions (e.g. `IOException` plus maybe others), but that would be an API change so is not an option right now. 
   
   The alternative would be to just add the above `SuppressWarnings` and never change the `throws` clause. The drawback of that would be that it doesn't address the warning that's generated at the use site.
   
   See also: https://bugs.openjdk.java.net/browse/JDK-8155591
   
   What's your preference?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org