You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/12/25 17:23:20 UTC
[PR] MINOR: New year code cleanup - include final keyword [kafka]
divijvaidya opened a new pull request, #15072:
URL: https://github.com/apache/kafka/pull/15072
Code cleanup to include `final` keyword where ever required. Detected via automatic tooling.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on PR #15072:
URL: https://github.com/apache/kafka/pull/15072#issuecomment-1869779489
The streams final rule also includes local variables, etc (which is quite noisy).
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #15072:
URL: https://github.com/apache/kafka/pull/15072#issuecomment-1887569050
The compilation is successful. This PR doesn't impact any runtime and hence, tests failing in CI can be ignored.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1448816308
##########
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/acl/StandardAuthorizerUpdateBenchmark.java:
##########
@@ -59,17 +59,15 @@
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class StandardAuthorizerUpdateBenchmark {
- @Param({"25000", "50000", "75000", "100000"})
- private int aclCount;
+ private static final Random RANDOM = new Random(System.currentTimeMillis());
private final String resourceNamePrefix = "foo-bar35_resource-";
Review Comment:
done
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1448815537
##########
clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java:
##########
@@ -64,11 +64,11 @@ public class MockConsumer<K, V> implements Consumer<K, V> {
private final Map<TopicPartition, OffsetAndMetadata> committed;
private final Queue<Runnable> pollTasks;
private final Set<TopicPartition> paused;
+ private final AtomicBoolean wakeup;
- private Map<TopicPartition, List<ConsumerRecord<K, V>>> records;
+ private final Map<TopicPartition, List<ConsumerRecord<K, V>>> records;
Review Comment:
done
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1436615442
##########
connect/api/src/main/java/org/apache/kafka/connect/data/SchemaProjector.java:
##########
@@ -37,13 +37,13 @@
public class SchemaProjector {
- private static Set<AbstractMap.SimpleImmutableEntry<Type, Type>> promotable = new HashSet<>();
+ private static final Set<AbstractMap.SimpleImmutableEntry<Type, Type>> PROMOTABLE = new HashSet<>();
Review Comment:
Added to the description and yes, checkstyle complained about it.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1442700296
##########
clients/src/main/java/org/apache/kafka/common/record/LazyDownConversionRecordsSend.java:
##########
@@ -36,9 +36,9 @@ public final class LazyDownConversionRecordsSend extends RecordsSend<LazyDownCon
private static final int MAX_READ_SIZE = 128 * 1024;
static final int MIN_OVERFLOW_MESSAGE_LENGTH = Records.LOG_OVERHEAD;
- private RecordValidationStats recordValidationStats;
+ private final RecordValidationStats recordValidationStats;
private RecordsSend convertedRecordsWriter;
- private Iterator<ConvertedRecords<?>> convertedRecordsIterator;
+ private final Iterator<ConvertedRecords<?>> convertedRecordsIterator;
Review Comment:
We can swap this line with the one above to group all final fields
##########
jmh-benchmarks/src/main/java/org/apache/kafka/jmh/acl/StandardAuthorizerUpdateBenchmark.java:
##########
@@ -59,17 +59,15 @@
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
public class StandardAuthorizerUpdateBenchmark {
- @Param({"25000", "50000", "75000", "100000"})
- private int aclCount;
+ private static final Random RANDOM = new Random(System.currentTimeMillis());
private final String resourceNamePrefix = "foo-bar35_resource-";
Review Comment:
Can we move this field down?
##########
clients/src/main/java/org/apache/kafka/clients/consumer/MockConsumer.java:
##########
@@ -64,11 +64,11 @@ public class MockConsumer<K, V> implements Consumer<K, V> {
private final Map<TopicPartition, OffsetAndMetadata> committed;
private final Queue<Runnable> pollTasks;
private final Set<TopicPartition> paused;
+ private final AtomicBoolean wakeup;
- private Map<TopicPartition, List<ConsumerRecord<K, V>>> records;
+ private final Map<TopicPartition, List<ConsumerRecord<K, V>>> records;
Review Comment:
Let's add the empty line after this field to separate the final fields from the other ones.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1436914220
##########
clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java:
##########
@@ -479,7 +479,7 @@ private static class NodeConnectionState {
private final String host;
private final HostResolver hostResolver;
private InetAddress lastAttemptedAddress;
- private Logger log;
+ private final Logger log;
Review Comment:
This is done in the latest commit.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #15072:
URL: https://github.com/apache/kafka/pull/15072#issuecomment-1870156605
Checkstyle doesn't have a rule [1] available to enforce that fields which are not changing are marked as final. Hence, I am not changing anything in the checkstyle here in this PR.
[1] https://checkstyle.sourceforge.io/checks.html
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #15072:
URL: https://github.com/apache/kafka/pull/15072#issuecomment-1887103085
I have rebased from trunk. Apologies that I didn't create a separate commit which would have made it easier to review the diff. Is there a better way to do it?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya merged PR #15072:
URL: https://github.com/apache/kafka/pull/15072
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1448815104
##########
clients/src/main/java/org/apache/kafka/common/record/LazyDownConversionRecordsSend.java:
##########
@@ -36,9 +36,9 @@ public final class LazyDownConversionRecordsSend extends RecordsSend<LazyDownCon
private static final int MAX_READ_SIZE = 128 * 1024;
static final int MIN_OVERFLOW_MESSAGE_LENGTH = Records.LOG_OVERHEAD;
- private RecordValidationStats recordValidationStats;
+ private final RecordValidationStats recordValidationStats;
private RecordsSend convertedRecordsWriter;
- private Iterator<ConvertedRecords<?>> convertedRecordsIterator;
+ private final Iterator<ConvertedRecords<?>> convertedRecordsIterator;
Review Comment:
done
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "vamossagar12 (via GitHub)" <gi...@apache.org>.
vamossagar12 commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1436578781
##########
connect/api/src/main/java/org/apache/kafka/connect/data/SchemaProjector.java:
##########
@@ -37,13 +37,13 @@
public class SchemaProjector {
- private static Set<AbstractMap.SimpleImmutableEntry<Type, Type>> promotable = new HashSet<>();
+ private static final Set<AbstractMap.SimpleImmutableEntry<Type, Type>> PROMOTABLE = new HashSet<>();
Review Comment:
nit: We should probably call out that the casing of variable(s) has been changed in the PR description? Currently it only says the usage of `final`..
##########
connect/api/src/main/java/org/apache/kafka/connect/data/SchemaProjector.java:
##########
@@ -37,13 +37,13 @@
public class SchemaProjector {
- private static Set<AbstractMap.SimpleImmutableEntry<Type, Type>> promotable = new HashSet<>();
+ private static final Set<AbstractMap.SimpleImmutableEntry<Type, Type>> PROMOTABLE = new HashSet<>();
Review Comment:
Also, wondering if this change got imposed due to a checkstyle?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "vamossagar12 (via GitHub)" <gi...@apache.org>.
vamossagar12 commented on PR #15072:
URL: https://github.com/apache/kafka/pull/15072#issuecomment-1870244078
Thanks @divijvaidya , I think Ismael's point is correct. From what I recall, the streams final rule also expects the method arguements etc to be final as well (apart from local variables within methods). Enabling that rule would be a big change I guess. Also, I see only variables and parameters [here](https://checkstyle.sourceforge.io/checks/coding/finallocalvariable.html#FinalLocalVariable) for tokens to check. I think we can leave it to this but the only problem is, there won't be any such enforcements for using final variables and might need cleanups in the future. That should be ok IMO.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1436615243
##########
clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java:
##########
@@ -479,7 +479,7 @@ private static class NodeConnectionState {
private final String host;
private final HostResolver hostResolver;
private InetAddress lastAttemptedAddress;
- private Logger log;
+ private final Logger log;
Review Comment:
ack. will change.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "ijuma (via GitHub)" <gi...@apache.org>.
ijuma commented on code in PR #15072:
URL: https://github.com/apache/kafka/pull/15072#discussion_r1436613486
##########
clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java:
##########
@@ -479,7 +479,7 @@ private static class NodeConnectionState {
private final String host;
private final HostResolver hostResolver;
private InetAddress lastAttemptedAddress;
- private Logger log;
+ private final Logger log;
Review Comment:
We typically have the final fields grouped first.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: New year code cleanup - include final keyword [kafka]
Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #15072:
URL: https://github.com/apache/kafka/pull/15072#issuecomment-1869776329
Thank you for the review @vamossagar12 . I didn't know about the checkstyle rule in streams. I will try & observe if enabling it for other modules leads to a large number of changes or not. I found this using intelliJ's code analysis.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org