diff --git a/buildSrc/src/main/java/org/apache/lucene/gradle/ErrorReportingTestListener.java b/buildSrc/src/main/java/org/apache/lucene/gradle/ErrorReportingTestListener.java index 9ba150909d8..64abfa5aec8 100644 --- a/buildSrc/src/main/java/org/apache/lucene/gradle/ErrorReportingTestListener.java +++ b/buildSrc/src/main/java/org/apache/lucene/gradle/ErrorReportingTestListener.java @@ -113,7 +113,7 @@ public class ErrorReportingTestListener implements TestOutputListener, TestListe if (echoOutput && !verboseMode) { synchronized (this) { - System.out.println(""); + System.out.println(); System.out.println(suite.getClassName() + " > test suite's output saved to " + outputLog + ", copied below:"); try (BufferedReader reader = Files.newBufferedReader(outputLog, StandardCharsets.UTF_8)) { char[] buf = new char[1024]; diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 025c7591154..22f4c05644d 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -200,6 +200,8 @@ Optimizations * GITHUB#13115: Short circuit queued flush check when flush on update is disabled (Prabhat Sharma) +* GITHUB#13085: Remove unnecessary toString() / substring() calls to save some String allocations (Dmitry Cherniachenko) + Bug Fixes --------------------- (No changes) diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemmer.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemmer.java index f999c25133f..94b684cd3d5 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemmer.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/br/BrazilianStemmer.java @@ -278,7 +278,7 @@ class BrazilianStemmer { return false; } - return value.substring(value.length() - suffix.length()).equals(suffix); + return value.endsWith(suffix); } /** diff --git a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/PatternParser.java b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/PatternParser.java index 3f746491da5..7f176cccb30 100644 --- a/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/PatternParser.java +++ b/lucene/analysis/common/src/java/org/apache/lucene/analysis/compound/hyphenation/PatternParser.java @@ -142,7 +142,7 @@ public class PatternParser extends DefaultHandler { break; } } - token.append(chars.toString().substring(0, i)); + token.append(chars, 0, i); // chars.delete(0,i); for (int countr = i; countr < chars.length(); countr++) { chars.setCharAt(countr - i, chars.charAt(countr)); diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java index 8e786aa59cc..d5122406261 100644 --- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java +++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/charfilter/TestHTMLStripCharFilter.java @@ -669,7 +669,7 @@ public class TestHTMLStripCharFilter extends BaseTokenStreamTestCase { builder.append((char) ch); } } catch (Exception e) { - if (gold.equals(builder.toString())) { + if (gold.contentEquals(builder)) { throw e; } throw new Exception( diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilter.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilter.java index 5b315cf3ce9..33348e26d7a 100644 --- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilter.java +++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/miscellaneous/TestTrimFilter.java @@ -30,19 +30,13 @@ import org.apache.lucene.tests.analysis.Token; public class TestTrimFilter extends BaseTokenStreamTestCase { public void testTrim() throws Exception { - char[] a = " a ".toCharArray(); - char[] b = "b ".toCharArray(); - char[] ccc = "cCc".toCharArray(); - char[] whitespace = " ".toCharArray(); - char[] empty = "".toCharArray(); - TokenStream ts = new CannedTokenStream( - new Token(new String(a, 0, a.length), 1, 5), - new Token(new String(b, 0, b.length), 6, 10), - new Token(new String(ccc, 0, ccc.length), 11, 15), - new Token(new String(whitespace, 0, whitespace.length), 16, 20), - new Token(new String(empty, 0, empty.length), 21, 21)); + new Token(" a ", 1, 5), + new Token("b ", 6, 10), + new Token("cCc", 11, 15), + new Token(" ", 16, 20), + new Token("", 21, 21)); ts = new TrimFilter(ts); assertTokenStreamContents(ts, new String[] {"a", "b", "cCc", "", ""}); diff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilter.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilter.java index e39bffb9c64..06553575e5f 100644 --- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilter.java +++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/pattern/TestPatternReplaceCharFilter.java @@ -82,8 +82,8 @@ public class TestPatternReplaceCharFilter extends BaseTokenStreamTestCase { indexMatched.append((cs.correctOffset(i) < 0 ? "-" : input.charAt(cs.correctOffset(i)))); } - boolean outputGood = expectedOutput.equals(output.toString()); - boolean indexMatchedGood = expectedIndexMatchedOutput.equals(indexMatched.toString()); + boolean outputGood = expectedOutput.contentEquals(output); + boolean indexMatchedGood = expectedIndexMatchedOutput.contentEquals(indexMatched); if (!outputGood || !indexMatchedGood || false) { System.out.println("Pattern : " + pattern); diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java index 8caa25bd8d6..cd0daa42d4b 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiContentSource.java @@ -112,13 +112,13 @@ public class EnwikiContentSource extends ContentSource { String time(String original) { StringBuilder buffer = new StringBuilder(); - buffer.append(original.substring(8, 10)); + buffer.append(original, 8, 10); buffer.append('-'); buffer.append(months[Integer.parseInt(original.substring(5, 7)) - 1]); buffer.append('-'); - buffer.append(original.substring(0, 4)); + buffer.append(original, 0, 4); buffer.append(' '); - buffer.append(original.substring(11, 19)); + buffer.append(original, 11, 19); buffer.append(".000"); return buffer.toString(); diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java index cdce0b479fb..f6ebae4158f 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFBISParser.java @@ -60,7 +60,7 @@ public class TrecFBISParser extends TrecDocParser { docData.setName(name); docData.setDate(date); docData.setTitle(title); - docData.setBody(stripTags(docBuf, mark).toString()); + docData.setBody(stripTags(docBuf, mark)); return docData; } } diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java index e2dae3ab775..06a4f0fbdd1 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFR94Parser.java @@ -53,14 +53,14 @@ public class TrecFR94Parser extends TrecDocParser { // date... String dateStr = extract(docBuf, DATE, DATE_END, h2, DATE_NOISE_PREFIXES); if (dateStr != null) { - dateStr = stripTags(dateStr, 0).toString(); + dateStr = stripTags(dateStr, 0); date = trecSrc.parseDate(dateStr.trim()); } } docData.clear(); docData.setName(name); docData.setDate(date); - docData.setBody(stripTags(docBuf, mark).toString()); + docData.setBody(stripTags(docBuf, mark)); return docData; } } diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java index 57762e884f0..a0d8e570cfa 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecFTParser.java @@ -52,7 +52,7 @@ public class TrecFTParser extends TrecDocParser { docData.setName(name); docData.setDate(date); docData.setTitle(title); - docData.setBody(stripTags(docBuf, mark).toString()); + docData.setBody(stripTags(docBuf, mark)); return docData; } } diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java index 933859e0ddb..186465a6a0d 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/TrecLATimesParser.java @@ -49,7 +49,7 @@ public class TrecLATimesParser extends TrecDocParser { if (d2a > 0) { dateStr = dateStr.substring(0, d2a + 3); // we need the "day" part } - dateStr = stripTags(dateStr, 0).toString(); + dateStr = stripTags(dateStr, 0); date = trecSrc.parseDate(dateStr.trim()); } @@ -59,14 +59,14 @@ public class TrecLATimesParser extends TrecDocParser { title = extract(docBuf, HEADLINE, HEADLINE_END, -1, null); } if (title != null) { - title = stripTags(title, 0).toString().trim(); + title = stripTags(title, 0).trim(); } docData.clear(); docData.setName(name); docData.setDate(date); docData.setTitle(title); - docData.setBody(stripTags(docBuf, mark).toString()); + docData.setBody(stripTags(docBuf, mark)); return docData; } } diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java index e8eb8f27042..8dc1ace3177 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/SearchWithSortTask.java @@ -59,7 +59,7 @@ public class SearchWithSortTask extends ReadTask { String typeString; if (index != -1) { fieldName = field.substring(0, index); - typeString = field.substring(1 + index, field.length()); + typeString = field.substring(1 + index); } else { throw new RuntimeException("You must specify the sort type ie page:int,subject:string"); } diff --git a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java index b0c19e8526e..d95e82f62ec 100644 --- a/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java +++ b/lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextStoredFieldsReader.java @@ -169,7 +169,7 @@ public class SimpleTextStoredFieldsReader extends StoredFieldsReader { if (type == TYPE_STRING) { byte[] bytes = new byte[scratch.length() - VALUE.length]; System.arraycopy(scratch.bytes(), VALUE.length, bytes, 0, bytes.length); - visitor.stringField(fieldInfo, new String(bytes, 0, bytes.length, StandardCharsets.UTF_8)); + visitor.stringField(fieldInfo, new String(bytes, StandardCharsets.UTF_8)); } else if (type == TYPE_BINARY) { byte[] copy = new byte[scratch.length() - VALUE.length]; System.arraycopy(scratch.bytes(), VALUE.length, copy, 0, copy.length); diff --git a/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java b/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java index 525381d60c9..bdfa78af87f 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/CodecUtil.java @@ -380,7 +380,7 @@ public final class CodecUtil { int suffixLength = in.readByte() & 0xFF; byte[] suffixBytes = new byte[suffixLength]; in.readBytes(suffixBytes, 0, suffixBytes.length); - String suffix = new String(suffixBytes, 0, suffixBytes.length, StandardCharsets.UTF_8); + String suffix = new String(suffixBytes, StandardCharsets.UTF_8); if (!suffix.equals(expectedSuffix)) { throw new CorruptIndexException( "file mismatch, expected suffix=" + expectedSuffix + ", got=" + suffix, in); diff --git a/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java b/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java index 968900c7f0c..b8459e42afa 100644 --- a/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java +++ b/lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java @@ -191,7 +191,7 @@ public final class IndexFileNames { if (idx == -1) { return null; } else { - return filename.substring(idx + 1, filename.length()); + return filename.substring(idx + 1); } } diff --git a/lucene/core/src/test/org/apache/lucene/analysis/standard/TestStandardAnalyzer.java b/lucene/core/src/test/org/apache/lucene/analysis/standard/TestStandardAnalyzer.java index 8fbe0359698..b51cdf86306 100644 --- a/lucene/core/src/test/org/apache/lucene/analysis/standard/TestStandardAnalyzer.java +++ b/lucene/core/src/test/org/apache/lucene/analysis/standard/TestStandardAnalyzer.java @@ -677,16 +677,11 @@ public class TestStandardAnalyzer extends BaseTokenStreamTestCase { public void testMaxTokenLengthDefault() throws Exception { StandardAnalyzer a = new StandardAnalyzer(); - StringBuilder bToken = new StringBuilder(); // exact max length: - for (int i = 0; i < StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH; i++) { - bToken.append('b'); - } - - String bString = bToken.toString(); + String bString = "b".repeat(StandardAnalyzer.DEFAULT_MAX_TOKEN_LENGTH); // first bString is exact max default length; next one is 1 too long String input = "x " + bString + " " + bString + "b"; - assertAnalyzesTo(a, input.toString(), new String[] {"x", bString, bString, "b"}); + assertAnalyzesTo(a, input, new String[] {"x", bString, bString, "b"}); a.close(); } diff --git a/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java b/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java index e05f3ae6633..4695c5b1f5e 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestPayloads.java @@ -18,7 +18,6 @@ package org.apache.lucene.index; import java.io.IOException; import java.io.StringReader; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; @@ -289,12 +288,10 @@ public class TestPayloads extends LuceneTestCase { reader.close(); } - static final Charset utf8 = StandardCharsets.UTF_8; - private void generateRandomData(byte[] data) { // this test needs the random data to be valid unicode String s = TestUtil.randomFixedByteLengthUnicodeString(random(), data.length); - byte[] b = s.getBytes(utf8); + byte[] b = s.getBytes(StandardCharsets.UTF_8); assert b.length == data.length; System.arraycopy(b, 0, data, 0, b.length); } @@ -493,7 +490,7 @@ public class TestPayloads extends LuceneTestCase { this.pool = pool; payload = pool.get(); generateRandomData(payload); - term = new String(payload, 0, payload.length, utf8); + term = new String(payload, StandardCharsets.UTF_8); first = true; payloadAtt = addAttribute(PayloadAttribute.class); termAtt = addAttribute(CharTermAttribute.class); diff --git a/lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java b/lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java index 80f61e6d171..0cb8b083057 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestPrefixRandom.java @@ -107,7 +107,7 @@ public class TestPrefixRandom extends LuceneTestCase { @Override public String toString(String field) { - return field.toString() + ":" + prefix.toString(); + return field + ":" + prefix; } @Override diff --git a/lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java b/lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java index 4b5f0eb5c08..5f48b0861bb 100644 --- a/lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java +++ b/lucene/core/src/test/org/apache/lucene/search/TestRegexpRandom2.java @@ -143,7 +143,7 @@ public class TestRegexpRandom2 extends LuceneTestCase { @Override public String toString(String field) { - return field.toString() + automaton.toString(); + return field + automaton; } @Override diff --git a/lucene/core/src/test/org/apache/lucene/util/automaton/TestLevenshteinAutomata.java b/lucene/core/src/test/org/apache/lucene/util/automaton/TestLevenshteinAutomata.java index 32fc2005cdd..c8adb8751b9 100644 --- a/lucene/core/src/test/org/apache/lucene/util/automaton/TestLevenshteinAutomata.java +++ b/lucene/core/src/test/org/apache/lucene/util/automaton/TestLevenshteinAutomata.java @@ -213,10 +213,10 @@ public class TestLevenshteinAutomata extends LuceneTestCase { List list = new ArrayList<>(); for (int i = 0; i < s.length() - 1; i++) { StringBuilder sb = new StringBuilder(); - sb.append(s.substring(0, i)); + sb.append(s, 0, i); sb.append(s.charAt(i + 1)); sb.append(s.charAt(i)); - sb.append(s.substring(i + 2, s.length())); + sb.append(s, i + 2, s.length()); String st = sb.toString(); if (!st.equals(s)) { list.add(Automata.makeString(st)); diff --git a/lucene/core/src/test/org/apache/lucene/util/automaton/TestRegExp.java b/lucene/core/src/test/org/apache/lucene/util/automaton/TestRegExp.java index c83f2631845..c934108115d 100644 --- a/lucene/core/src/test/org/apache/lucene/util/automaton/TestRegExp.java +++ b/lucene/core/src/test/org/apache/lucene/util/automaton/TestRegExp.java @@ -119,7 +119,7 @@ public class TestRegExp extends LuceneTestCase { // Add any head to the result, unchanged if (substitutionPoint > 0) { - result.append(docValue.substring(0, substitutionPoint)); + result.append(docValue, 0, substitutionPoint); } // Modify the middle... diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java index 4f2d4af6da0..dfedf7974fd 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java @@ -1398,7 +1398,7 @@ public class UnifiedHighlighter { curValueBuilder.append(curValue); } curValueBuilder.append(valueSeparator); - curValueBuilder.append(value.substring(0, Math.min(lengthBudget - 1, value.length()))); + curValueBuilder.append(value, 0, Math.min(lengthBudget - 1, value.length())); values[currentField] = curValueBuilder; } diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java index 83b1d78d685..d5da92c5300 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/surround/query/BooleanQueryTestFacade.java @@ -114,7 +114,7 @@ public class BooleanQueryTestFacade { public void doTest() throws Exception { if (verbose) { - System.out.println(""); + System.out.println(); System.out.println("Query: " + queryText); } diff --git a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java index 8fe372feec3..642f466bc03 100644 --- a/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java +++ b/lucene/spatial-extras/src/java/org/apache/lucene/spatial/prefix/RecursivePrefixTreeStrategy.java @@ -113,7 +113,7 @@ public class RecursivePrefixTreeStrategy extends PrefixTreeStrategy { if (pointsOnly) str.append(",pointsOnly"); if (pruneLeafyBranches) str.append(",pruneLeafyBranches"); if (prefixGridScanLevel != grid.getMaxLevels() - 4) - str.append(",prefixGridScanLevel:").append("").append(prefixGridScanLevel); + str.append(",prefixGridScanLevel:").append(prefixGridScanLevel); if (!multiOverlappingIndexedShapes) str.append(",!multiOverlappingIndexedShapes"); return str.append(')').toString(); } diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java index e1772102098..afaf304a4ad 100644 --- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java +++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java @@ -927,7 +927,7 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable { return; } sb.append(""); - sb.append(surface.substring(0, prefixToken.length())); + sb.append(surface, 0, prefixToken.length()); sb.append(""); sb.append(surface.substring(prefixToken.length())); } diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestAnalyzingInfixSuggester.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestAnalyzingInfixSuggester.java index 2361f6b0c31..6983c7eba59 100644 --- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestAnalyzingInfixSuggester.java +++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestAnalyzingInfixSuggester.java @@ -892,7 +892,7 @@ public class TestAnalyzingInfixSuggester extends LuceneTestCase { b.append(""); b.append(queryTerm); b.append(""); - b.append(inputTerm.substring(queryTerm.length(), inputTerm.length())); + b.append(inputTerm.substring(queryTerm.length())); matched = true; break; } diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/English.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/English.java index c78fb7ac362..5b48b617e72 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/English.java +++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/English.java @@ -166,7 +166,6 @@ public final class English { result.append("one "); break; case 0: - result.append(""); break; } } diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LineFileDocs.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LineFileDocs.java index e0158c4c542..91b897ffb70 100644 --- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LineFileDocs.java +++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LineFileDocs.java @@ -307,7 +307,7 @@ public class LineFileDocs implements Closeable { throw new RuntimeException("line: [" + line + "] is in an invalid format !"); } - docState.body.setStringValue(line.substring(1 + spot2, line.length())); + docState.body.setStringValue(line.substring(1 + spot2)); final String title = line.substring(0, spot); docState.title.setStringValue(title); docState.titleTokenized.setStringValue(title);