-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Use Objects.equals() instead of == to compare strings #77840
Conversation
Signed-off-by: xingrufei <xingrufei@sogou-inc.com>
Pinging @elastic/es-search (Team:Search) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @skyguard1, thanks for catching this. I left two very small asks, otherwise LGTM. I will go ahead and run our CI tests once you adressed those two comments.
@@ -749,7 +749,7 @@ private GetAliasesRequest createGetAliasesRequest(FieldCapabilitiesResponse resp | |||
} else { | |||
// if the field type is the same across all this alias' indices, check the field's capabilities (searchable/aggregatable) | |||
for (Entry<String, FieldCapabilities> type : types.entrySet()) { | |||
if (type.getKey() == UNMAPPED) { | |||
if (Objects.equals(type.getKey(), UNMAPPED)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another similar comparison in L713, would you mind correcting that as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
@@ -97,7 +97,7 @@ public void add(Term[] terms) { | |||
*/ | |||
public void add(Term[] terms, int position) { | |||
for (int i = 0; i < terms.length; i++) { | |||
if (terms[i].field() != field) { | |||
if (!Objects.equals(terms[i].field(), field)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small styling issue: we prefer to make negative statements more explicit by using "v == false" instead of "!v". Even though it is more verbose it helps readability. So in this case "Objects.equals(terms[i].field(), field) == false" would be preferable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done it
Signed-off-by: xingrufei <xingrufei@sogou-inc.com>
@elasticmachine test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM
Not sure why the ci build failed. Maybe ci build can be triggered again? |
Pinging @elastic/es-ql (Team:QL) |
@elasticmachine run elasticsearch-ci/packaging-tests-windows-sample |
@elasticmachine update branch |
@elasticmachine test this please |
💚 Backport successful
|
* master: (185 commits) Implement get and containsKey in terms of the wrapped innerMap (elastic#77965) Adjust Lucene version and enable BWC tests (elastic#77933) Disable BWC to upgrade to Lucene-8.10-snapshot Reenable MlDistributedFailureIT [DOCS] Fix typo for `script.painless.regex.enabled` setting value (elastic#77853) Upgrade to Lucene-8.10.0-snapshot-bf2fcb53079 (elastic#77801) [DOCS] Fix ESS install lead-in (elastic#77887) Resolve thirdparty gradle plugin artifacts from mavencentral (elastic#77865) Reduce the number of times that `LifecycleExecutionState` is parsed when running a policy. (elastic#77863) Utility methods to add and remove backing indices from data streams (elastic#77778) Use Objects.equals() instead of == to compare strings (elastic#77840) [ML] prefer least allocated model when a new node is added to the cluster (elastic#77756) Deprecate ignore_throttled parameter (elastic#77479) Improve LifecycleExecutionState parsing. (elastic#77855) [DOCS] Removes deprecated word from HLRC title. (elastic#77851) Remove legacy geo code from AggregationResultUtils (elastic#77702) Adjust SearchableSnapshotsBlobStoreCacheIntegTests.testBlobStoreCache (elastic#77758) Laxify SecureSM to allow creation of the JDK's innocuous threads (elastic#77789) [Test] Reduce concurrency when testing creation of security index (elastic#75293) Refactor metric PipelineAggregation integration test (elastic#77548) ... # Conflicts: # server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java
Use Objects.equals() instead of == to compare strings in
MultiPhrasePrefixQuery
andIndexResolver
, thanks