Skip to content

Commit

Permalink
Compare strings with equals() instead of ==
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Kryukov <dk2k@ya.ru>
  • Loading branch information
dk2k committed Aug 22, 2024
1 parent abb1041 commit af992a9
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -105,7 +106,7 @@ public List<String> resolveIndexAbstractions(

// we always need to check for date math expressions
final String dateMathName = indexNameExpressionResolver.resolveDateMathExpression(indexAbstraction);
if (dateMathName != indexAbstraction) {
if (!Objects.equals(dateMathName, indexAbstraction)) {
assert dateMathName.equals(indexAbstraction) == false;
if (replaceWildcards && Regex.isSimpleMatchPattern(dateMathName)) {
// continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,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)) {
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 @@ -210,7 +210,7 @@ SortedDocsProducer createSortedDocsProducerOrNull(IndexReader reader, Query quer

if (fieldType instanceof NumberFieldMapper.NumberFieldType) {
NumberFieldMapper.NumberFieldType ft = (NumberFieldMapper.NumberFieldType) fieldType;
if (ft.typeName() == "unsigned_long") {
if ("unsigned_long".equals(ft.typeName())) {
return new UnsignedLongPointsSortedDocsProducer(fieldType.name(), lowerPoint, upperPoint);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public void reset(TokenStream stream) {
public void nextToken() throws IOException {
anyTokens = true;
BytesRef term = fillBytesRef(termsRef);
if (requireUnigram && typeAttribute.type() == ShingleFilter.DEFAULT_TOKEN_TYPE) {
if (requireUnigram && ShingleFilter.DEFAULT_TOKEN_TYPE.equals(typeAttribute.type())) {
return;
}
anyUnigram = true;
if (posIncAttr.getPositionIncrement() == 0 && typeAttribute.type() == SynonymFilter.TYPE_SYNONYM) {
if (posIncAttr.getPositionIncrement() == 0 && SynonymFilter.TYPE_SYNONYM.equals(typeAttribute.type())) {
assert currentSet != null;
TermStats termStats = generator.termStats(term);
if (termStats.docFreq > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ protected IndexShard newShard(
Settings nodeSettings = Settings.builder().put("node.name", routing.currentNodeId()).build();
DiscoveryNodes discoveryNodes = IndexShardTestUtils.getFakeDiscoveryNodes(routing);
// To simulate that the node is remote backed
if (indexMetadata.getSettings().get(IndexMetadata.SETTING_REMOTE_STORE_ENABLED) == "true") {
if ("true".equals(indexMetadata.getSettings().get(IndexMetadata.SETTING_REMOTE_STORE_ENABLED))) {
nodeSettings = Settings.builder()
.put("node.name", routing.currentNodeId())
.put("node.attr.remote_store.translog.repository", "seg_repo")
Expand Down

0 comments on commit af992a9

Please sign in to comment.