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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) == false) {
throw new IllegalArgumentException(
"All phrase terms must be in the same field (" + field + "): "
+ terms[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ private static Map<String, InvalidMappedField> getInvalidFieldsForAliases(String
// iterate over each type
for (Entry<String, FieldCapabilities> type : types.entrySet()) {
String esFieldType = type.getKey();
if (esFieldType == UNMAPPED) {
if (Objects.equals(esFieldType, UNMAPPED)) {
continue;
}
String[] indices = type.getValue().indices();
Expand Down Expand Up @@ -749,7 +749,7 @@ private static Map<String, InvalidMappedField> getInvalidFieldsForAliases(String
} 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

continue;
}
FieldCapabilities f = type.getValue();
Expand Down