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 2022/08/18 10:42:34 UTC

[GitHub] [kafka] mdedetrich opened a new pull request, #12534: MINOR; Use underscore for variable initialization in KafkaServer

mdedetrich opened a new pull request, #12534:
URL: https://github.com/apache/kafka/pull/12534

   In Scala its standard practice to use _ whenever you are initializing
   variables. In regard to implementation, for object references
   _ initialization maps to null so there is no change in behaviour.
   
   This PR is the equivalent of https://github.com/apache/kafka/pull/12471 but for KafkaServer
   


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


[GitHub] [kafka] mdedetrich commented on a diff in pull request #12534: MINOR; Use underscore for variable initialization in Scala sources

Posted by GitBox <gi...@apache.org>.
mdedetrich commented on code in PR #12534:
URL: https://github.com/apache/kafka/pull/12534#discussion_r949867626


##########
core/src/main/scala/kafka/server/ControllerServer.scala:
##########
@@ -78,18 +78,18 @@ class ControllerServer(
   val awaitShutdownCond = lock.newCondition()
   var status: ProcessStatus = SHUTDOWN
 
-  var linuxIoMetricsCollector: LinuxIoMetricsCollector = null
-  @volatile var authorizer: Option[Authorizer] = null
-  var tokenCache: DelegationTokenCache = null
-  var credentialProvider: CredentialProvider = null
-  var socketServer: SocketServer = null
+  var linuxIoMetricsCollector: LinuxIoMetricsCollector = _
+  @volatile var authorizer: Option[Authorizer] = _

Review Comment:
   I just noticed this and maybe it makes sense to initialize this to `None` rather than `_`?
   
   Not sure if it would break anything but its definitely more idiomatic/correct.



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


[GitHub] [kafka] mdedetrich commented on pull request #12534: MINOR; Use underscore for variable initialization in KafkaServer

Posted by GitBox <gi...@apache.org>.
mdedetrich commented on PR #12534:
URL: https://github.com/apache/kafka/pull/12534#issuecomment-1219341093

   @mimaison Since you reviewed https://github.com/apache/kafka/pull/12471 can you have a look at this PR (once the CI is happy of course)?


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


[GitHub] [kafka] mimaison commented on a diff in pull request #12534: MINOR; Use underscore for variable initialization in Scala sources

Posted by GitBox <gi...@apache.org>.
mimaison commented on code in PR #12534:
URL: https://github.com/apache/kafka/pull/12534#discussion_r952554375


##########
core/src/main/scala/kafka/server/ControllerServer.scala:
##########
@@ -78,18 +78,18 @@ class ControllerServer(
   val awaitShutdownCond = lock.newCondition()
   var status: ProcessStatus = SHUTDOWN
 
-  var linuxIoMetricsCollector: LinuxIoMetricsCollector = null
-  @volatile var authorizer: Option[Authorizer] = null
-  var tokenCache: DelegationTokenCache = null
-  var credentialProvider: CredentialProvider = null
-  var socketServer: SocketServer = null
+  var linuxIoMetricsCollector: LinuxIoMetricsCollector = _
+  @volatile var authorizer: Option[Authorizer] = _

Review Comment:
   I took a quick look and I think we should be able to make that 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


[GitHub] [kafka] mimaison merged pull request #12534: MINOR; Use underscore for variable initialization in Scala sources

Posted by GitBox <gi...@apache.org>.
mimaison merged PR #12534:
URL: https://github.com/apache/kafka/pull/12534


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


[GitHub] [kafka] mimaison commented on pull request #12534: MINOR; Use underscore for variable initialization in KafkaServer

Posted by GitBox <gi...@apache.org>.
mimaison commented on PR #12534:
URL: https://github.com/apache/kafka/pull/12534#issuecomment-1219749268

   Thanks for the PR!
   I did a quick search and it looks like there are 200+ such instances across 40+ files. If you want to address them all, maybe let's group them in 1 or 2 PRs.


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


[GitHub] [kafka] mdedetrich commented on pull request #12534: MINOR; Use underscore for variable initialization in KafkaServer

Posted by GitBox <gi...@apache.org>.
mdedetrich commented on PR #12534:
URL: https://github.com/apache/kafka/pull/12534#issuecomment-1219791330

   Sure thing will do.


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


[GitHub] [kafka] mdedetrich commented on a diff in pull request #12534: MINOR; Use underscore for variable initialization in Scala sources

Posted by GitBox <gi...@apache.org>.
mdedetrich commented on code in PR #12534:
URL: https://github.com/apache/kafka/pull/12534#discussion_r949867626


##########
core/src/main/scala/kafka/server/ControllerServer.scala:
##########
@@ -78,18 +78,18 @@ class ControllerServer(
   val awaitShutdownCond = lock.newCondition()
   var status: ProcessStatus = SHUTDOWN
 
-  var linuxIoMetricsCollector: LinuxIoMetricsCollector = null
-  @volatile var authorizer: Option[Authorizer] = null
-  var tokenCache: DelegationTokenCache = null
-  var credentialProvider: CredentialProvider = null
-  var socketServer: SocketServer = null
+  var linuxIoMetricsCollector: LinuxIoMetricsCollector = _
+  @volatile var authorizer: Option[Authorizer] = _

Review Comment:
   I just noticed this and maybe it makes sense to initialize this to `None` rather than `_`?



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


[GitHub] [kafka] mdedetrich commented on a diff in pull request #12534: MINOR; Use underscore for variable initialization in Scala sources

Posted by GitBox <gi...@apache.org>.
mdedetrich commented on code in PR #12534:
URL: https://github.com/apache/kafka/pull/12534#discussion_r952585957


##########
core/src/main/scala/kafka/server/ControllerServer.scala:
##########
@@ -78,18 +78,18 @@ class ControllerServer(
   val awaitShutdownCond = lock.newCondition()
   var status: ProcessStatus = SHUTDOWN
 
-  var linuxIoMetricsCollector: LinuxIoMetricsCollector = null
-  @volatile var authorizer: Option[Authorizer] = null
-  var tokenCache: DelegationTokenCache = null
-  var credentialProvider: CredentialProvider = null
-  var socketServer: SocketServer = null
+  var linuxIoMetricsCollector: LinuxIoMetricsCollector = _
+  @volatile var authorizer: Option[Authorizer] = _

Review Comment:
   Just committed the change, also rebased the PR to latest trunk



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


[GitHub] [kafka] mdedetrich commented on pull request #12534: MINOR; Use underscore for variable initialization in Scala sources

Posted by GitBox <gi...@apache.org>.
mdedetrich commented on PR #12534:
URL: https://github.com/apache/kafka/pull/12534#issuecomment-1219980341

   @mimaison PR has been updated as you wanted.


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