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

Use Objects.equals() instead of == to compare strings #77840

Merged
merged 3 commits into from
Sep 16, 2021

Conversation

skyguard1
Copy link
Contributor

Use Objects.equals() instead of == to compare strings in MultiPhrasePrefixQuery and IndexResolver, thanks

Signed-off-by: xingrufei <xingrufei@sogou-inc.com>
@elasticsearchmachine elasticsearchmachine added v8.0.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Sep 16, 2021
@pugnascotia pugnascotia added the :Search/Search Search-related issues that do not fall into other categories label Sep 16, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Sep 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

Copy link
Member

@cbuescher cbuescher left a 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)) {
Copy link
Member

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?

Copy link
Contributor Author

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)) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've done it

@cbuescher cbuescher self-assigned this Sep 16, 2021
Signed-off-by: xingrufei <xingrufei@sogou-inc.com>
@cbuescher
Copy link
Member

@elasticmachine test this please

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM

@skyguard1
Copy link
Contributor Author

skyguard1 commented Sep 16, 2021

Not sure why the ci build failed. Maybe ci build can be triggered again?

@astefan astefan added the Team:QL (Deprecated) Meta label for query languages team label Sep 16, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@cbuescher
Copy link
Member

@elasticmachine run elasticsearch-ci/packaging-tests-windows-sample

@cbuescher
Copy link
Member

@elasticmachine update branch

@cbuescher
Copy link
Member

@elasticmachine test this please

@cbuescher cbuescher added v7.16.0 auto-backport-and-merge Automatically create backport pull requests and merge when ready labels Sep 16, 2021
@cbuescher cbuescher merged commit 9984c48 into elastic:master Sep 16, 2021
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 16, 2021
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
7.x

elasticsearchmachine pushed a commit that referenced this pull request Sep 16, 2021
Co-authored-by: skyguard1 <qhdxssm@qq.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
wjp719 added a commit to wjp719/elasticsearch that referenced this pull request Sep 18, 2021
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport-and-merge Automatically create backport pull requests and merge when ready external-contributor Pull request authored by a developer outside the Elasticsearch team >non-issue :Search/Search Search-related issues that do not fall into other categories Team:QL (Deprecated) Meta label for query languages team Team:Search Meta label for search team v7.16.0 v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants