Skip to content

HIVE-28876 Strings should be compared with equals(), not with == #5744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dk2k
Copy link
Contributor

@dk2k dk2k commented Apr 2, 2025

Comparison with == and != checks memory adresses
equals() check values

Copy link

sonarqubecloud bot commented Apr 2, 2025

Copy link

@aturoczy aturoczy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fill out the PR description accordingly.

@@ -361,8 +361,8 @@ public static boolean isCreateOperation(DDLOperation<?> ddlOperation) {
}

private static String getMetricStageName(String stageName, ReplicationMetricCollector metricCollector) {
if( stageName == "REPL_DUMP" || stageName == "REPL_LOAD" || stageName == "ATLAS_DUMP" || stageName == "ATLAS_LOAD"
|| stageName == "RANGER_DUMP" || stageName == "RANGER_LOAD" || stageName == "RANGER_DENY"){
if( "REPL_DUMP".equals(stageName) || "REPL_LOAD".equals(stageName) || "ATLAS_DUMP".equals(stageName) || "ATLAS_LOAD".equals(stageName)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not have to much sentiment if the string is equals or ==. Both are acceptable. I would chime @deniskuzZ and @ayushtkn to tell which is the most commonly used style in Hive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Java the == operator compares only the references not the actual content of the objects so this change is needed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants