You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/06/17 08:42:05 UTC

[GitHub] [spark] dcoliversun opened a new pull request, #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

dcoliversun opened a new pull request, #36900:
URL: https://github.com/apache/spark/pull/36900

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR aims to make `equals` method invoked by No-null object to avoid NPE.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Since NullPointerException can possibly be thrown while calling the equals method of Object, equals should be invoked by a constant or an object that is definitely not null.
   
   > Positive example: "test".equals(object);
   > Counter example: object.equals("test");
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   No.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   No need to add tests because this PR just changes object invoked.


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on PR #36900:
URL: https://github.com/apache/spark/pull/36900#issuecomment-1159851122

   @dongjoon-hyun Thanks for your advise. As you said, This PR is no longer about no-null object invokes equals to avoid NPE. I will close this PR and submit a new PR.


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900528871


##########
sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionImplUtils.java:
##########
@@ -62,13 +62,13 @@ private static byte[] aesInternal(
       }
 
     try {
-      if (mode.equalsIgnoreCase("ECB") &&
-          (padding.equalsIgnoreCase("PKCS") || padding.equalsIgnoreCase("DEFAULT"))) {
+      if ("ECB".equalsIgnoreCase(mode) &&
+          ("PKCS".equalsIgnoreCase(padding) || "DEFAULT".equalsIgnoreCase(padding))) {
         Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
         cipher.init(opmode, secretKey);
         return cipher.doFinal(input, 0, input.length);
-      } else if (mode.equalsIgnoreCase("GCM") &&
-          (padding.equalsIgnoreCase("NONE") || padding.equalsIgnoreCase("DEFAULT"))) {
+      } else if ("GCM".equalsIgnoreCase(mode) &&
+          ("NONE".equalsIgnoreCase(padding) || "DEFAULT".equalsIgnoreCase(padding))) {

Review Comment:
   Could you revert these changes of this file, @dcoliversun ?
   This is logically impossible because `aesInternal` is `private static` and used in the constructor with `mode.toString()`.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899918895


##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalBlockHandler.java:
##########
@@ -394,7 +394,7 @@ private class ManagedBufferIterator implements Iterator<ManagedBuffer> {
         size = reduceIdAndChunkIds.length;
         blockDataForIndexFn = index -> mergeManager.getMergedBlockData(msg.appId, shuffleId,
           shuffleMergeId, reduceIdAndChunkIds[index], reduceIdAndChunkIds[index + 1]);
-      } else if (blockId0Parts.length == 3 && blockId0Parts[0].equals("rdd")) {
+      } else if (blockId0Parts.length == 3 && "rdd".equals(blockId0Parts[0])) {

Review Comment:
   In what scenario `blockId0Parts[0]` is null?
   
   



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900042748


##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalBlockHandler.java:
##########
@@ -394,7 +394,7 @@ private class ManagedBufferIterator implements Iterator<ManagedBuffer> {
         size = reduceIdAndChunkIds.length;
         blockDataForIndexFn = index -> mergeManager.getMergedBlockData(msg.appId, shuffleId,
           shuffleMergeId, reduceIdAndChunkIds[index], reduceIdAndChunkIds[index + 1]);
-      } else if (blockId0Parts.length == 3 && blockId0Parts[0].equals("rdd")) {
+      } else if (blockId0Parts.length == 3 && "rdd".equals(blockId0Parts[0])) {

Review Comment:
   Just defensive programming. It's possible that `blockId0Parts[0]` is null and no possible that `"rdd"` is null



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900045440


##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:
##########
@@ -282,8 +282,8 @@ private String getIpAddress() {
     String clientIpAddress;
     // Http transport mode.
     // We set the thread local ip address, in ThriftHttpServlet.
-    if (cliService.getHiveConf().getVar(
-        ConfVars.HIVE_SERVER2_TRANSPORT_MODE).equalsIgnoreCase("http")) {
+    if ("http".equalsIgnoreCase(cliService.getHiveConf().getVar(

Review Comment:
   OK. If these are copied from Apache Hive, it's better to submit PR to Hive and cherry pick



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899911591


##########
common/network-common/src/main/java/org/apache/spark/network/TransportContext.java:
##########
@@ -124,7 +124,7 @@ public TransportContext(
     this.closeIdleConnections = closeIdleConnections;
 
     if (conf.getModuleName() != null &&
-        conf.getModuleName().equalsIgnoreCase("shuffle") &&
+        "shuffle".equalsIgnoreCase(conf.getModuleName()) &&

Review Comment:
   hmm... if `conf.getModuleName() != null` is true,  I think NPE won't happen here
   
   



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900530677


##########
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalBlockHandler.java:
##########
@@ -394,7 +394,7 @@ private class ManagedBufferIterator implements Iterator<ManagedBuffer> {
         size = reduceIdAndChunkIds.length;
         blockDataForIndexFn = index -> mergeManager.getMergedBlockData(msg.appId, shuffleId,
           shuffleMergeId, reduceIdAndChunkIds[index], reduceIdAndChunkIds[index + 1]);
-      } else if (blockId0Parts.length == 3 && blockId0Parts[0].equals("rdd")) {
+      } else if (blockId0Parts.length == 3 && "rdd".equals(blockId0Parts[0])) {

Review Comment:
   Unfortunately, it doesn't looks like this code has any improvement like you claimed, @dcoliversun .
   If `blockID0Parts[0] == null`, it fails already at line 383 before reaches this line 397.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899931139


##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftHttpCLIService.java:
##########
@@ -194,7 +194,7 @@ public void run() {
    * @return
    */
   private String getHttpPath(String httpPath) {
-    if(httpPath == null || httpPath.equals("")) {
+    if(httpPath == null || httpPath.isEmpty()) {

Review Comment:
   ditto



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899930383


##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:
##########
@@ -282,8 +282,8 @@ private String getIpAddress() {
     String clientIpAddress;
     // Http transport mode.
     // We set the thread local ip address, in ThriftHttpServlet.
-    if (cliService.getHiveConf().getVar(
-        ConfVars.HIVE_SERVER2_TRANSPORT_MODE).equalsIgnoreCase("http")) {
+    if ("http".equalsIgnoreCase(cliService.getHiveConf().getVar(

Review Comment:
   This file copy from `hive`, I think it's best not to touch it to avoid conflict, If there is a bug here, can we change hive first and then cherry pick
   
   
   
   



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] codecov-commenter commented on pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #36900:
URL: https://github.com/apache/spark/pull/36900#issuecomment-1158757800

   # [Codecov](https://codecov.io/gh/apache/spark/pull/36900?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#36900](https://codecov.io/gh/apache/spark/pull/36900?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (75b3965) into [master](https://codecov.io/gh/apache/spark/commit/75b396505a266e839b9e2dc1d3ec36eebb6deb43?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (75b3965) will **not change** coverage.
   > The diff coverage is `n/a`.
   
   > :exclamation: Current head 75b3965 differs from pull request most recent head 4796d9c. Consider uploading reports for the commit 4796d9c to get more accurate results
   
   ```diff
   @@           Coverage Diff           @@
   ##           master   #36900   +/-   ##
   =======================================
     Coverage   67.87%   67.87%           
   =======================================
     Files         160      160           
     Lines       43525    43525           
     Branches     6933     6933           
   =======================================
     Hits        29544    29544           
     Misses      12982    12982           
     Partials      999      999           
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | unittests | `67.87% <0.00%> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/spark/pull/36900?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/spark/pull/36900?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [75b3965...4796d9c](https://codecov.io/gh/apache/spark/pull/36900?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on PR #36900:
URL: https://github.com/apache/spark/pull/36900#issuecomment-1158673708

   Can one of the admins verify this patch?


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900531182


##########
common/network-common/src/main/java/org/apache/spark/network/TransportContext.java:
##########
@@ -123,8 +123,7 @@ public TransportContext(
     this.rpcHandler = rpcHandler;
     this.closeIdleConnections = closeIdleConnections;
 
-    if (conf.getModuleName() != null &&
-        conf.getModuleName().equalsIgnoreCase("shuffle") &&
+    if ("shuffle".equalsIgnoreCase(conf.getModuleName()) &&

Review Comment:
   Previously, there is no NPE in this case. So, this is just a code-implication instead of avoiding any NPE.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899911591


##########
common/network-common/src/main/java/org/apache/spark/network/TransportContext.java:
##########
@@ -124,7 +124,7 @@ public TransportContext(
     this.closeIdleConnections = closeIdleConnections;
 
     if (conf.getModuleName() != null &&
-        conf.getModuleName().equalsIgnoreCase("shuffle") &&
+        "shuffle".equalsIgnoreCase(conf.getModuleName()) &&

Review Comment:
   hmm... if `conf.getModuleName() != null` is true,  I think NPE won't happen here
   
   or should we remove `conf.getModuleName() != null` when `"shuffle".equalsIgnoreCase(conf.getModuleName()`?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899911591


##########
common/network-common/src/main/java/org/apache/spark/network/TransportContext.java:
##########
@@ -124,7 +124,7 @@ public TransportContext(
     this.closeIdleConnections = closeIdleConnections;
 
     if (conf.getModuleName() != null &&
-        conf.getModuleName().equalsIgnoreCase("shuffle") &&
+        "shuffle".equalsIgnoreCase(conf.getModuleName()) &&

Review Comment:
   hmm... if `conf.getModuleName() != null` is true,  I think NPE won't happen here
   
   or should we remove `conf.getModuleName() != null` ?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899940309


##########
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/SpecificParquetRecordReaderBase.java:
##########
@@ -128,7 +128,7 @@ public void initialize(InputSplit inputSplit, TaskAttemptContext taskAttemptCont
     TaskContext taskContext = TaskContext$.MODULE$.get();
     if (taskContext != null) {
       Option<AccumulatorV2<?, ?>> accu = taskContext.taskMetrics().externalAccums().lastOption();
-      if (accu.isDefined() && accu.get().getClass().getSimpleName().equals("NumRowGroupsAcc")) {
+      if (accu.isDefined() && "NumRowGroupsAcc".equals(accu.get().getClass().getSimpleName())) {

Review Comment:
   ok, back off



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899940555


##########
common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java:
##########
@@ -319,7 +319,7 @@ public static void throwException(Throwable t) {
   static {
     boolean _unaligned;
     String arch = System.getProperty("os.arch", "");
-    if (arch.equals("ppc64le") || arch.equals("ppc64") || arch.equals("s390x")) {
+    if ("ppc64le".equals(arch) || "ppc64".equals(arch) || "s390x".equals(arch)) {

Review Comment:
   no scenario. back off



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r901304165


##########
launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java:
##########
@@ -401,8 +401,7 @@ boolean isClientMode(Map<String, String> userProps) {
    * Return whether the given main class represents a thrift server.
    */
   private boolean isThriftServer(String mainClass) {
-    return (mainClass != null &&
-      mainClass.equals("org.apache.spark.sql.hive.thriftserver.HiveThriftServer2"));
+    return ("org.apache.spark.sql.hive.thriftserver.HiveThriftServer2".equals(mainClass));

Review Comment:
   It's needed. If remove `mainClass != null`, pyspark test will fail.
   ```plain
   ========================================================================
   Running PySpark tests
   ========================================================================
   Running PySpark tests. Output is in /__w/spark/spark/python/unit-tests.log
   Will test against the following Python executables: ['python3.9', 'pypy3']
   Will test the following Python modules: ['pyspark-sql', 'pyspark-resource', 'pyspark-mllib']
   python3.9 python_implementation is CPython
   python3.9 version is: Python 3.9.5
   pypy3 python_implementation is PyPy
   pypy3 version is: Python 3.7.12 (7.3.7+dfsg-1~ppa1~ubuntu20.04, Oct 26 2021, 02:00:43)
   [PyPy 7.3.7 with GCC 9.3.0]
   Starting test(pypy3): pyspark.sql.tests.test_arrow (temp output: /tmp/pypy3__pyspark.sql.tests.test_arrow__2_kthvri.log)
   Finished test(pypy3): pyspark.sql.tests.test_arrow (1s) ... 121 tests were skipped
   Starting test(pypy3): pyspark.sql.tests.test_arrow_map (temp output: /tmp/pypy3__pyspark.sql.tests.test_arrow_map__ot8ujcj9.log)
   Finished test(pypy3): pyspark.sql.tests.test_arrow_map (0s) ... 7 tests were skipped
   Starting test(pypy3): pyspark.sql.tests.test_catalog (temp output: /tmp/pypy3__pyspark.sql.tests.test_catalog__67s8rrv3.log)
   Exception in thread "main" java.lang.NullPointerException
   	at org.apache.spark.launcher.SparkSubmitCommandBuilder.isThriftServer(SparkSubmitCommandBuilder.java:404)
   	at org.apache.spark.launcher.SparkSubmitCommandBuilder.buildSparkSubmitCommand(SparkSubmitCommandBuilder.java:265)
   	at org.apache.spark.launcher.SparkSubmitCommandBuilder.buildCommand(SparkSubmitCommandBuilder.java:164)
   	at org.apache.spark.launcher.Main.buildCommand(Main.java:113)
   	at org.apache.spark.launcher.Main.main(Main.java:63)
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900060625


##########
common/network-common/src/main/java/org/apache/spark/network/util/TransportConf.java:
##########
@@ -306,7 +306,7 @@ public long maxChunksBeingTransferred() {
    * ceiling of the nearest integer.
    */
   public int chunkFetchHandlerThreads() {
-    if (!this.getModuleName().equalsIgnoreCase("shuffle")) {
+    if (!"shuffle".equalsIgnoreCase(this.getModuleName())) {

Review Comment:
   OK, it's better



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900531182


##########
common/network-common/src/main/java/org/apache/spark/network/TransportContext.java:
##########
@@ -123,8 +123,7 @@ public TransportContext(
     this.rpcHandler = rpcHandler;
     this.closeIdleConnections = closeIdleConnections;
 
-    if (conf.getModuleName() != null &&
-        conf.getModuleName().equalsIgnoreCase("shuffle") &&
+    if ("shuffle".equalsIgnoreCase(conf.getModuleName()) &&

Review Comment:
   Previously, there is no NPE in this case. So, this is just a code-implication instead of avoiding any NPE.
   In other words, this contribution is unmatched with the PR title.



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899921970


##########
common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java:
##########
@@ -319,7 +319,7 @@ public static void throwException(Throwable t) {
   static {
     boolean _unaligned;
     String arch = System.getProperty("os.arch", "");
-    if (arch.equals("ppc64le") || arch.equals("ppc64") || arch.equals("s390x")) {
+    if ("ppc64le".equals(arch) || "ppc64".equals(arch) || "s390x".equals(arch)) {

Review Comment:
   In what scenario`System.getProperty("os.arch", ""` is null?



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899930383


##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:
##########
@@ -282,8 +282,8 @@ private String getIpAddress() {
     String clientIpAddress;
     // Http transport mode.
     // We set the thread local ip address, in ThriftHttpServlet.
-    if (cliService.getHiveConf().getVar(
-        ConfVars.HIVE_SERVER2_TRANSPORT_MODE).equalsIgnoreCase("http")) {
+    if ("http".equalsIgnoreCase(cliService.getHiveConf().getVar(

Review Comment:
   This file copy from `hive`, It's best not to touch it to avoid conflict
   
   



##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java:
##########
@@ -282,8 +282,8 @@ private String getIpAddress() {
     String clientIpAddress;
     // Http transport mode.
     // We set the thread local ip address, in ThriftHttpServlet.
-    if (cliService.getHiveConf().getVar(
-        ConfVars.HIVE_SERVER2_TRANSPORT_MODE).equalsIgnoreCase("http")) {
+    if ("http".equalsIgnoreCase(cliService.getHiveConf().getVar(

Review Comment:
   This file copy from `hive`, I think it's best not to touch it to avoid conflict
   
   



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899932016


##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/thrift/ThriftHttpServlet.java:
##########
@@ -553,7 +553,7 @@ private static String getDoAsQueryParam(String queryString) {
     Map<String, String[]> params = javax.servlet.http.HttpUtils.parseQueryString( queryString );
     Set<String> keySet = params.keySet();
     for (String key: keySet) {
-      if (key.equalsIgnoreCase("doAs")) {
+      if ("doAs".equalsIgnoreCase(key)) {

Review Comment:
   ditto



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun closed pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun closed pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE
URL: https://github.com/apache/spark/pull/36900


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899916743


##########
common/network-common/src/main/java/org/apache/spark/network/util/TransportConf.java:
##########
@@ -306,7 +306,7 @@ public long maxChunksBeingTransferred() {
    * ceiling of the nearest integer.
    */
   public int chunkFetchHandlerThreads() {
-    if (!this.getModuleName().equalsIgnoreCase("shuffle")) {
+    if (!"shuffle".equalsIgnoreCase(this.getModuleName())) {

Review Comment:
   https://github.com/apache/spark/blob/75b396505a266e839b9e2dc1d3ec36eebb6deb43/common/network-common/src/main/java/org/apache/spark/network/util/TransportConf.java#L51-L55
   
   Maybe we should change line 55 to `this.module = Objects.requireNonNull(module);` to ensure `this.module` is not null, 



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899924370


##########
sql/core/src/main/java/org/apache/spark/sql/execution/datasources/parquet/SpecificParquetRecordReaderBase.java:
##########
@@ -128,7 +128,7 @@ public void initialize(InputSplit inputSplit, TaskAttemptContext taskAttemptCont
     TaskContext taskContext = TaskContext$.MODULE$.get();
     if (taskContext != null) {
       Option<AccumulatorV2<?, ?>> accu = taskContext.taskMetrics().externalAccums().lastOption();
-      if (accu.isDefined() && accu.get().getClass().getSimpleName().equals("NumRowGroupsAcc")) {
+      if (accu.isDefined() && "NumRowGroupsAcc".equals(accu.get().getClass().getSimpleName())) {

Review Comment:
   if `accu.isDefined()` is true, It's hard to imagine that `getClass().getSimpleName()` is null
   
   



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dcoliversun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dcoliversun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r899940951


##########
common/network-common/src/main/java/org/apache/spark/network/TransportContext.java:
##########
@@ -124,7 +124,7 @@ public TransportContext(
     this.closeIdleConnections = closeIdleConnections;
 
     if (conf.getModuleName() != null &&
-        conf.getModuleName().equalsIgnoreCase("shuffle") &&
+        "shuffle".equalsIgnoreCase(conf.getModuleName()) &&

Review Comment:
   remove not null logic



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on code in PR #36900:
URL: https://github.com/apache/spark/pull/36900#discussion_r900529739


##########
launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java:
##########
@@ -401,8 +401,7 @@ boolean isClientMode(Map<String, String> userProps) {
    * Return whether the given main class represents a thrift server.
    */
   private boolean isThriftServer(String mainClass) {
-    return (mainClass != null &&
-      mainClass.equals("org.apache.spark.sql.hive.thriftserver.HiveThriftServer2"));
+    return ("org.apache.spark.sql.hive.thriftserver.HiveThriftServer2".equals(mainClass));

Review Comment:
   Is this needed? It looks like we already have some defensive code for this `private boolean isThriftServer`.
   
   https://github.com/apache/spark/blob/cb0ef06b641845be5774b18c9c24d67c6ab4561a/launcher/src/main/java/org/apache/spark/launcher/SparkSubmitCommandBuilder.java#L235



-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] dongjoon-hyun commented on pull request #36900: [SPARK-39504][CORE][SQL] No-null object invokes equals method to avoid NPE

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on PR #36900:
URL: https://github.com/apache/spark/pull/36900#issuecomment-1159279060

   BTW, thank you for your review, @LuciferYang !


-- 
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: reviews-unsubscribe@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org