From 67104dd615c82de64839de60418110211438f574 Mon Sep 17 00:00:00 2001 From: Koen De Groote Date: Mon, 10 Jun 2019 18:07:43 +0200 Subject: [PATCH] LUCENE-8847: Code Cleanup: Rewrite StringBuilder.append with concatted strings (#707) This specific commit affects all points in the casebase where the argument of a StringBuilder.append() call is itself a regular String concatenation. This defeats the purpose of using StringBuilder and also introduces an extra alloction. These changes should avoid that. ant tests have run, succeeded on local machine. Removing test files from the changes. Another suggested rework. --- lucene/CHANGES.txt | 4 ++ .../PartOfSpeechAttributeImpl.java | 2 +- .../analysis/cn/smart/hhmm/BiSegGraph.java | 2 +- .../analysis/cn/smart/hhmm/SegGraph.java | 2 +- .../src/java/org/egothor/stemmer/Diff.java | 14 +++--- .../byTask/feeds/AbstractQueryMaker.java | 2 +- .../byTask/feeds/ContentItemsSource.java | 8 +-- .../benchmark/byTask/tasks/TaskSequence.java | 6 +-- .../quality/trec/TrecTopicsReader.java | 4 +- .../lucene/document/LatLonPointSortField.java | 2 +- .../org/apache/lucene/index/MergePolicy.java | 2 +- .../org/apache/lucene/index/MultiBits.java | 8 +-- .../java/org/apache/lucene/index/Terms.java | 10 ++-- .../org/apache/lucene/util/UnicodeUtil.java | 2 +- .../lucene/util/automaton/Automaton.java | 4 +- .../lucene/util/automaton/RunAutomaton.java | 2 +- .../java/org/apache/lucene/util/fst/FST.java | 10 ++-- .../org/apache/lucene/facet/FacetResult.java | 2 +- .../lucene/facet/range/LongRangeCounter.java | 4 +- .../directory/DirectoryTaxonomyReader.java | 6 +-- .../lucene/index/memory/MemoryIndex.java | 16 +++--- .../lucene/misc/SweetSpotSimilarity.java | 3 +- .../queryparser/classic/ParseException.java | 2 +- .../queryparser/classic/TokenMgrError.java | 2 +- .../flexible/core/nodes/AnyQueryNode.java | 3 +- .../core/nodes/ProximityQueryNode.java | 3 +- .../standard/parser/ParseException.java | 2 +- .../standard/parser/TokenMgrError.java | 2 +- .../surround/parser/ParseException.java | 2 +- .../surround/parser/TokenMgrError.java | 2 +- .../lucene/document/LatLonShapeLineQuery.java | 2 +- .../document/LatLonShapePolygonQuery.java | 2 +- .../org/apache/lucene/geo/Tessellator.java | 4 +- .../lucene/search/TermAutomatonQuery.java | 4 +- .../prefix/NumberRangePrefixTreeStrategy.java | 4 +- .../prefix/RecursivePrefixTreeStrategy.java | 2 +- .../apache/lucene/spatial3d/Geo3DPoint.java | 6 +-- .../spatial3d/Geo3DPointOutsideSortField.java | 2 +- .../lucene/spatial3d/Geo3DPointSortField.java | 2 +- .../jaspell/JaspellTernarySearchTrie.java | 4 +- .../lucene/geo/BaseGeoPointTestCase.java | 38 +++++++------- .../org/apache/lucene/geo/EarthDebugger.java | 50 +++++++++---------- .../org/apache/lucene/geo/GeoTestUtil.java | 8 +-- .../search/BaseRangeFieldQueryTestCase.java | 14 +++--- .../apache/lucene/util/LuceneTestCase.java | 4 +- .../lucene/validation/LicenseCheckTask.java | 4 +- .../extraction/XLSXResponseWriter.java | 6 +-- .../autoscaling/sim/SimCloudManager.java | 28 +++++------ .../java/org/apache/solr/core/PluginInfo.java | 10 ++-- .../admin/SegmentsInfoRequestHandler.java | 4 +- .../apache/solr/handler/export/SortDoc.java | 4 +- .../apache/solr/parser/ParseException.java | 2 +- .../org/apache/solr/parser/TokenMgrError.java | 2 +- .../solr/schema/SimplePreAnalyzedParser.java | 12 ++--- .../org/apache/solr/search/QueryParsing.java | 7 ++- .../apache/solr/search/join/GraphQuery.java | 12 ++--- .../solr/update/SolrCmdDistributor.java | 2 +- .../apache/solr/update/SplitIndexCommand.java | 14 +++--- .../org/apache/solr/util/SimplePostTool.java | 2 +- .../org/apache/solr/util/SolrLogLayout.java | 10 ++-- .../org/apache/solr/util/SolrPluginUtils.java | 2 +- .../client/solrj/io/stream/Facet2DStream.java | 16 +++--- .../client/solrj/io/stream/FacetStream.java | 10 ++-- .../client/solrj/io/stream/KnnStream.java | 2 +- .../solrj/io/stream/TimeSeriesStream.java | 10 ++-- .../client/solrj/request/UpdateRequest.java | 6 +-- .../solr/common/cloud/ClusterState.java | 6 +-- .../solr/common/cloud/SolrZkClient.java | 9 ++-- .../apache/solr/common/util/ExecutorUtil.java | 2 +- .../cloud/AbstractFullDistribZkTestBase.java | 2 +- .../org/apache/solr/cloud/ChaosMonkey.java | 2 +- 71 files changed, 231 insertions(+), 234 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 1c818bdb695..369340ccb00 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -93,6 +93,10 @@ Test Framework * LUCENE-8825: CheckHits now display the shard index in case of mismatch between top hits. (Atri Sharma via Adrien Grand) +Other + +* LUCENE-8847: Code Cleanup: Remove StringBuilder.append with concatted strings + ======================= Lucene 8.1.1 ======================= (No Changes) diff --git a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/tokenattributes/PartOfSpeechAttributeImpl.java b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/tokenattributes/PartOfSpeechAttributeImpl.java index fbd637f92b2..14a40b651cc 100644 --- a/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/tokenattributes/PartOfSpeechAttributeImpl.java +++ b/lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/tokenattributes/PartOfSpeechAttributeImpl.java @@ -80,7 +80,7 @@ public class PartOfSpeechAttributeImpl extends AttributeImpl implements PartOfSp if (builder.length() > 0) { builder.append("+"); } - builder.append(morpheme.surfaceForm + "/" + morpheme.posTag.name() + "(" + morpheme.posTag.description() + ")"); + builder.append(morpheme.surfaceForm).append('/').append(morpheme.posTag.name()).append('(').append(morpheme.posTag.description()).append(')'); } return builder.toString(); } diff --git a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java index 33074983543..2c92b083fa3 100644 --- a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java +++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/BiSegGraph.java @@ -222,7 +222,7 @@ class BiSegGraph { Collection> values = tokenPairListTable.values(); for (ArrayList segList : values) { for (SegTokenPair pair : segList) { - sb.append(pair + "\n"); + sb.append(pair).append("\n"); } } return sb.toString(); diff --git a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java index a6f38b31759..e01438cf0d7 100644 --- a/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java +++ b/lucene/analysis/smartcn/src/java/org/apache/lucene/analysis/cn/smart/hhmm/SegGraph.java @@ -136,7 +136,7 @@ class SegGraph { List tokenList = this.toTokenList(); StringBuilder sb = new StringBuilder(); for (SegToken t : tokenList) { - sb.append(t + "\n"); + sb.append(t).append("\n"); } return sb.toString(); } diff --git a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Diff.java b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Diff.java index fe50449b7d4..da720fcfc0e 100644 --- a/lucene/analysis/stempel/src/java/org/egothor/stemmer/Diff.java +++ b/lucene/analysis/stempel/src/java/org/egothor/stemmer/Diff.java @@ -239,7 +239,7 @@ public class Diff { switch (way[x][y]) { case X: if (equals != base) { - result.append("-" + (equals)); + result.append('-').append(equals); equals = base; } deletes++; @@ -248,11 +248,11 @@ public class Diff { // delete case Y: if (deletes != base) { - result.append("D" + (deletes)); + result.append('D').append(deletes); deletes = base; } if (equals != base) { - result.append("-" + (equals)); + result.append('-').append(equals); equals = base; } result.append('I'); @@ -261,11 +261,11 @@ public class Diff { // insert case R: if (deletes != base) { - result.append("D" + (deletes)); + result.append('D').append(deletes); deletes = base; } if (equals != base) { - result.append("-" + (equals)); + result.append('-').append(equals); equals = base; } result.append('R'); @@ -275,7 +275,7 @@ public class Diff { // replace case D: if (deletes != base) { - result.append("D" + (deletes)); + result.append('D').append(deletes); deletes = base; } equals++; @@ -286,7 +286,7 @@ public class Diff { } } if (deletes != base) { - result.append("D" + (deletes)); + result.append('D').append(deletes); deletes = base; } diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/AbstractQueryMaker.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/AbstractQueryMaker.java index b40f4a91d46..a56f9786080 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/AbstractQueryMaker.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/AbstractQueryMaker.java @@ -50,7 +50,7 @@ public abstract class AbstractQueryMaker implements QueryMaker { StringBuilder sb = new StringBuilder(); if (queries != null) { for (int i = 0; i < queries.length; i++) { - sb.append(i+". "+ queries[i].getClass().getSimpleName()+" - "+queries[i].toString()); + sb.append(i).append(". ").append(queries[i].getClass().getSimpleName()).append(" - ").append(queries[i].toString()); sb.append(newline); } } diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ContentItemsSource.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ContentItemsSource.java index 7e15083a27e..385edc8f2f6 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ContentItemsSource.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ContentItemsSource.java @@ -159,19 +159,19 @@ public abstract class ContentItemsSource implements Closeable { int nut = getTotalItemsCount(); if (nut > lastPrintedNumUniqueTexts) { print = true; - sb.append("total count of "+itemsName+": ").append(Format.format(0,nut,col)).append(newline); + sb.append("total count of ").append(itemsName).append(": ").append(Format.format(0,nut,col)).append(newline); lastPrintedNumUniqueTexts = nut; } long nub = getTotalBytesCount(); if (nub > lastPrintedNumUniqueBytes) { print = true; - sb.append("total bytes of "+itemsName+": ").append(Format.format(0,nub,col)).append(newline); + sb.append("total bytes of ").append(itemsName).append(": ").append(Format.format(0,nub,col)).append(newline); lastPrintedNumUniqueBytes = nub; } if (getItemsCount() > 0) { print = true; - sb.append("num "+itemsName+" added since last inputs reset: ").append(Format.format(0,getItemsCount(),col)).append(newline); - sb.append("total bytes added for "+itemsName+" since last inputs reset: ").append(Format.format(0,getBytesCount(),col)).append(newline); + sb.append("num ").append(itemsName).append(" added since last inputs reset: ").append(Format.format(0,getItemsCount(),col)).append(newline); + sb.append("total bytes added for ").append(itemsName).append(" since last inputs reset: ").append(Format.format(0,getBytesCount(),col)).append(newline); } if (print) { System.out.println(sb.append(newline).toString()); diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java index c57845da621..4b2f94c2b2b 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java @@ -436,14 +436,14 @@ public class TaskSequence extends PerfTask { sb.append(padd); sb.append(!letChildReport ? ">" : (parallel ? "]" : "}")); if (fixedTime) { - sb.append(" " + NumberFormat.getNumberInstance(Locale.ROOT).format(runTimeSec) + "s"); + sb.append(' ').append(NumberFormat.getNumberInstance(Locale.ROOT).format(runTimeSec)).append('s'); } else if (repetitions>1) { - sb.append(" * " + repetitions); + sb.append(" * ").append(repetitions); } else if (repetitions==REPEAT_EXHAUST) { sb.append(" * EXHAUST"); } if (rate>0) { - sb.append(", rate: " + rate+"/"+(perMin?"min":"sec")); + sb.append(", rate: ").append(rate).append('/').append(perMin ? "min" : "sec"); } if (getRunInBackground()) { sb.append(" &"); diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java index 8c478ab3c0b..99e628ae15c 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/quality/trec/TrecTopicsReader.java @@ -122,13 +122,13 @@ public class TrecTopicsReader { } if (line.startsWith(prefix)) { if (collectMatchLine) { - sb.append(sep+line); + sb.append(sep).append(line); sep = newline; } break; } if (collectAll) { - sb.append(sep+line); + sb.append(sep).append(line); sep = newline; } } diff --git a/lucene/core/src/java/org/apache/lucene/document/LatLonPointSortField.java b/lucene/core/src/java/org/apache/lucene/document/LatLonPointSortField.java index 10e72cc2e98..8d6f652ed83 100644 --- a/lucene/core/src/java/org/apache/lucene/document/LatLonPointSortField.java +++ b/lucene/core/src/java/org/apache/lucene/document/LatLonPointSortField.java @@ -92,7 +92,7 @@ final class LatLonPointSortField extends SortField { builder.append(" longitude="); builder.append(longitude); if (Double.POSITIVE_INFINITY != getMissingValue()) { - builder.append(" missingValue=" + getMissingValue()); + builder.append(" missingValue=").append(getMissingValue()); } builder.append('>'); return builder.toString(); diff --git a/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java b/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java index d552d74ba49..dc8a1d3d885 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java +++ b/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java @@ -303,7 +303,7 @@ public abstract class MergePolicy { b.append(" into ").append(info.info.name); } if (maxNumSegments != -1) { - b.append(" [maxNumSegments=" + maxNumSegments + "]"); + b.append(" [maxNumSegments=").append(maxNumSegments).append(']'); } if (isAborted()) { b.append(" [ABORTED]"); diff --git a/lucene/core/src/java/org/apache/lucene/index/MultiBits.java b/lucene/core/src/java/org/apache/lucene/index/MultiBits.java index b1f5f51d532..27e7e0cb8cf 100644 --- a/lucene/core/src/java/org/apache/lucene/index/MultiBits.java +++ b/lucene/core/src/java/org/apache/lucene/index/MultiBits.java @@ -98,18 +98,18 @@ public final class MultiBits implements Bits { @Override public String toString() { StringBuilder b = new StringBuilder(); - b.append(subs.length + " subs: "); + b.append(subs.length).append(" subs: "); for(int i=0;i implements Accountable { @Override public String toString() { StringBuilder b = new StringBuilder(); - b.append(" target=" + target); - b.append(" label=0x" + Integer.toHexString(label)); + b.append(" target=").append(target); + b.append(" label=0x").append(Integer.toHexString(label)); if (flag(BIT_FINAL_ARC)) { b.append(" final"); } @@ -223,13 +223,13 @@ public final class FST implements Accountable { b.append(" stop"); } if (flag(BIT_ARC_HAS_OUTPUT)) { - b.append(" output=" + output); + b.append(" output=").append(output); } if (flag(BIT_ARC_HAS_FINAL_OUTPUT)) { - b.append(" nextFinalOutput=" + nextFinalOutput); + b.append(" nextFinalOutput=").append(nextFinalOutput); } if (bytesPerArc != 0) { - b.append(" arcArray(idx=" + arcIdx + " of " + numArcs + ")"); + b.append(" arcArray(idx=").append(arcIdx).append(" of ").append(numArcs).append(")"); } return b.toString(); } diff --git a/lucene/facet/src/java/org/apache/lucene/facet/FacetResult.java b/lucene/facet/src/java/org/apache/lucene/facet/FacetResult.java index 7635364337a..5ca221b809c 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/FacetResult.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/FacetResult.java @@ -60,7 +60,7 @@ public final class FacetResult { sb.append(childCount); sb.append('\n'); for(LabelAndValue labelValue : labelValues) { - sb.append(" " + labelValue + "\n"); + sb.append(" ").append(labelValue).append("\n"); } return sb.toString(); } diff --git a/lucene/facet/src/java/org/apache/lucene/facet/range/LongRangeCounter.java b/lucene/facet/src/java/org/apache/lucene/facet/range/LongRangeCounter.java index 5c625f08867..855f6ec09b4 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/range/LongRangeCounter.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/range/LongRangeCounter.java @@ -295,9 +295,9 @@ final class LongRangeCounter { indent(sb, depth); if (left == null) { assert right == null; - sb.append("leaf: " + start + " to " + end); + sb.append("leaf: ").append(start).append(" to ").append(end); } else { - sb.append("node: " + start + " to " + end); + sb.append("node: ").append(start).append(" to ").append(end); } if (outputs != null) { sb.append(" outputs="); diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java index c97325cf44d..bcc4c6d5189 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java @@ -412,14 +412,14 @@ public class DirectoryTaxonomyReader extends TaxonomyReader implements Accountab try { FacetLabel category = this.getPath(i); if (category == null) { - sb.append(i + ": NULL!! \n"); + sb.append(i).append(": NULL!! \n"); continue; } if (category.length == 0) { - sb.append(i + ": EMPTY STRING!! \n"); + sb.append(i).append(": EMPTY STRING!! \n"); continue; } - sb.append(i +": "+category.toString()+"\n"); + sb.append(i).append(": ").append(category.toString()).append("\n"); } catch (IOException e) { if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, e.getMessage(), e); diff --git a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java index b061d51093a..ca9ccd75fa8 100644 --- a/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java +++ b/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java @@ -728,7 +728,7 @@ public class MemoryIndex { String fieldName = entry.getKey(); Info info = entry.getValue(); info.sortTerms(); - result.append(fieldName + ":\n"); + result.append(fieldName).append(":\n"); SliceByteStartArray sliceArray = info.sliceArray; int numPositions = 0; SliceReader postingsReader = new SliceReader(intBlockPool); @@ -736,7 +736,7 @@ public class MemoryIndex { int ord = info.sortedTerms[j]; info.terms.get(ord, spare); int freq = sliceArray.freq[ord]; - result.append("\t'" + spare + "':" + freq + ":"); + result.append("\t'").append(spare).append("':").append(freq).append(':'); postingsReader.reset(sliceArray.start[ord], sliceArray.end[ord]); result.append(" ["); final int iters = storeOffsets ? 3 : 1; @@ -752,7 +752,7 @@ public class MemoryIndex { if (storePayloads) { int payloadIndex = postingsReader.readInt(); if (payloadIndex != -1) { - result.append(", " + payloadsBytesRefs.get(payloadBuilder, payloadIndex)); + result.append(", ").append(payloadsBytesRefs.get(payloadBuilder, payloadIndex)); } } result.append(")"); @@ -767,16 +767,16 @@ public class MemoryIndex { numPositions += freq; } - result.append("\tterms=" + info.terms.size()); - result.append(", positions=" + numPositions); + result.append("\tterms=").append(info.terms.size()); + result.append(", positions=").append(numPositions); result.append("\n"); sumPositions += numPositions; sumTerms += info.terms.size(); } - result.append("\nfields=" + fields.size()); - result.append(", terms=" + sumTerms); - result.append(", positions=" + sumPositions); + result.append("\nfields=").append(fields.size()); + result.append(", terms=").append(sumTerms); + result.append(", positions=").append(sumPositions); return result.toString(); } diff --git a/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java b/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java index 537322793ce..9287a750ef4 100644 --- a/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java +++ b/lucene/misc/src/java/org/apache/lucene/misc/SweetSpotSimilarity.java @@ -207,8 +207,7 @@ public class SweetSpotSimilarity extends ClassicSimilarity { public String toString() { StringBuilder sb = new StringBuilder(); sb.append("SweetSpotSimilarity") - .append("(") - .append("ln_min="+ln_min+", ") + .append('(').append("ln_min=").append(ln_min).append(", ") .append("ln_max=").append(ln_max).append(", ") .append("ln_steep=").append(ln_steep).append(", ") .append("tf_base=").append(tf_base).append(", ") diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java index 3c02be3f004..fe20c105483 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/ParseException.java @@ -173,7 +173,7 @@ public class ParseException extends Exception { default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java index ad111d0cd26..17abedfefb5 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/TokenMgrError.java @@ -82,7 +82,7 @@ public class TokenMgrError extends Error default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/AnyQueryNode.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/AnyQueryNode.java index a6874eee448..1e1592eee45 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/AnyQueryNode.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/nodes/AnyQueryNode.java @@ -109,8 +109,7 @@ public class AnyQueryNode extends AndQueryNode { return ""; StringBuilder sb = new StringBuilder(); - sb.append(""); + sb.append(""; StringBuilder sb = new StringBuilder(); - sb.append(""); + sb.append(""); for (QueryNode child : getChildren()) { sb.append("\n"); sb.append(child.toString()); diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java index c3511a178a4..dadcb99c6c2 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java @@ -176,7 +176,7 @@ public class ParseException extends QueryNodeParseException { default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java index f2ef4a57eb3..2cab350fcb5 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java @@ -82,7 +82,7 @@ public class TokenMgrError extends Error default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java index 4059bda68cc..6924da1b388 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/ParseException.java @@ -173,7 +173,7 @@ public class ParseException extends Exception { default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java index 77e740f34ba..ba3297e855c 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/TokenMgrError.java @@ -82,7 +82,7 @@ public class TokenMgrError extends Error default: if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) { String s = "0000" + Integer.toString(ch, 16); - retval.append("\\u" + s.substring(s.length() - 4, s.length())); + retval.append("\\u").append(s.substring(s.length() - 4, s.length())); } else { retval.append(ch); } diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeLineQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeLineQuery.java index e7933457c3c..fcc2590dfdf 100644 --- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeLineQuery.java +++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapeLineQuery.java @@ -111,7 +111,7 @@ final class LatLonShapeLineQuery extends LatLonShapeQuery { sb.append(this.field); sb.append(':'); } - sb.append("Line(" + lines[0].toGeoJSON() + ")"); + sb.append("Line(").append(lines[0].toGeoJSON()).append(')'); return sb.toString(); } diff --git a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapePolygonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapePolygonQuery.java index 94dde0d4948..97e739ea5b7 100644 --- a/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapePolygonQuery.java +++ b/lucene/sandbox/src/java/org/apache/lucene/document/LatLonShapePolygonQuery.java @@ -100,7 +100,7 @@ final class LatLonShapePolygonQuery extends LatLonShapeQuery { sb.append(this.field); sb.append(':'); } - sb.append("Polygon(" + polygons[0].toGeoJSON() + ")"); + sb.append("Polygon(").append(polygons[0].toGeoJSON()).append(')'); return sb.toString(); } diff --git a/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java b/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java index 195e4a6c4d3..950ebd8e987 100644 --- a/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java +++ b/lucene/sandbox/src/java/org/apache/lucene/geo/Tessellator.java @@ -873,12 +873,12 @@ final public class Tessellator { if (this.previous == null) builder.append("||-"); else - builder.append(this.previous.idx + " <- "); + builder.append(this.previous.idx).append(" <- "); builder.append(this.idx); if (this.next == null) builder.append(" -||"); else - builder.append(" -> " + this.next.idx); + builder.append(" -> ").append(this.next.idx); return builder.toString(); } } diff --git a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java index cd123af3693..ff2147e50bf 100644 --- a/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java +++ b/lucene/sandbox/src/java/org/apache/lucene/search/TermAutomatonQuery.java @@ -284,9 +284,9 @@ public class TermAutomatonQuery extends Query { b.append(" "); b.append(state); if (det.isAccept(state)) { - b.append(" [shape=doublecircle,label=\"" + state + "\"]\n"); + b.append(" [shape=doublecircle,label=\"").append(state).append("\"]\n"); } else { - b.append(" [shape=circle,label=\"" + state + "\"]\n"); + b.append(" [shape=circle,label=\"").append(state).append("\"]\n"); } int numTransitions = det.initTransition(state, t); for(int i=0;i\n"); b.append("