Skip to content
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

[YSQL] java unit test uses == for string comparison #23612

Closed
1 task done
myang2021 opened this issue Aug 23, 2024 · 0 comments
Closed
1 task done

[YSQL] java unit test uses == for string comparison #23612

myang2021 opened this issue Aug 23, 2024 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue

Comments

@myang2021
Copy link
Contributor

myang2021 commented Aug 23, 2024

Jira Link: DB-12524

Description

boolean is_wait_on_conflict_concurrency_control = (enable_wait_queues == "true");

Based upon https://stackoverflow.com/questions/61024135/why-cant-we-use-instead-of-equals-methods-to-compare-string-objects

"==" compares Object references with each other and not their literal values. If both the variables point to same object, it will return true. So,

String s1 = new String("hello");
String s2 = new String("hello");
Here s1==s2, will return false as both are different objects.

When you use equals(), it will compare the literal values of the content and give its results.

So the test is not doing what it intended to do because is_wait_on_conflict_concurrency_control is false.

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@myang2021 myang2021 added the area/ysql Yugabyte SQL (YSQL) label Aug 23, 2024
@myang2021 myang2021 self-assigned this Aug 23, 2024
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Aug 23, 2024
myang2021 added a commit that referenced this issue Aug 26, 2024
Summary:
The buggy code is
```
boolean is_wait_on_conflict_concurrency_control = (enable_wait_queues == "true");
```

One answer from stackoverflow:

In java, "==" compares Object references with each other and not their literal
values. If both the variables point to same object, it will return true. So,

String s1 = new String("hello");
String s2 = new String("hello");
Here s1==s2, will return false as both are different objects.

When you use equals(), it will compare the literal values of the content and give its results.

So the test is not doing what it intended to do because
is_wait_on_conflict_concurrency_control is false.

Also fixed another place where we can see misleading WARNING log for a valid
gflag.
Jira: DB-12524

Test Plan: ./yb_build.sh --java-test org.yb.pgsql.TestPgTransparentRestarts

Reviewers: kfranz

Reviewed By: kfranz

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D37516
jasonyb pushed a commit that referenced this issue Aug 28, 2024
Summary:
 0c5102e [doc][yba] xCluster Replication update (#23417)
 Excluded: a9466df [#22325] YSQL, QueryDiagnostics: Adding a catalog view for queryDiagnostics
 b9597b3 [#23612] YSQL: Fix java unit test misuse of == for string comparison
 bb72624 [#23613] DocDB: Framework for different vector index coordinate types, SIFT 1B hnsw_tool support
 12032f3 [PLAT-12510] Add option to use UTC for cron expression backup schedule time calculation
 Excluded: 141703a [#22533] YSQL: fix setrefs for index scan
 1bb8c62 [#23543] docdb: Update tablegroup manager in RepartitionTable
 1e28b8a [#23518] Do not include full snapshot info for list snapshot schedules RPC.
 e98c383 [PLAT-15048] Fix auto-master failover local test
 f606132 [doc][yba] Backup clarification (#23611)
 e80d60f [PLAT-14973] Precheck for node agent install to verify that we have correct permissions to execute in the installer directory
 5230f5a [#23630]yugabyted: Modiying the APIs required for the new Migrate Schema Page.
 0a310d3 [PLAT-15042] Add default pitr retention period
 aa15c81 [PLAT-12435] Adding a precheck for libselinux bindings for system python3
 525672e [#23632] DocDB: Unify GetFlagInfos and remove duplicate code
 4ab5ca0 [#23601] YSQL: Fix TestPreparedStatements tests with connection manager enabled
 57a7690 [PLAT-12222][PLAT-15036][PLAT-14333] Add connection pooling support for create universe API
 3407682 [PLAT-10119]: Do not allow back-tick for DB password in YBA

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Differential Revision: https://phorge.dev.yugabyte.com/D37578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

2 participants