diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 62f4763325e..bd38f3f30cb 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -259,6 +259,10 @@ Optimizations * LUCENE-7742: Fix places where we were unboxing and then re-boxing according to FindBugs (Daniel Jelinski via Mike McCandless) +* LUCENE-7739: Fix places where we unnecessarily boxed while parsing + a numeric value according to FindBugs (Daniel Jelinski via Mike + McCandless) + Build * LUCENE-7653: Update randomizedtesting to version 2.5.0. (Dawid Weiss) 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 a933e562789..7258476357a 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 @@ -101,7 +101,7 @@ public class EnwikiContentSource extends ContentSource { buffer.append(original.substring(8, 10)); buffer.append('-'); - buffer.append(months[Integer.valueOf(original.substring(5, 7)).intValue() - 1]); + buffer.append(months[Integer.parseInt(original.substring(5, 7)) - 1]); buffer.append('-'); buffer.append(original.substring(0, 4)); buffer.append(' '); diff --git a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java index 40a3637750e..292642f3607 100644 --- a/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java +++ b/lucene/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ForceMergeTask.java @@ -46,7 +46,7 @@ public class ForceMergeTask extends PerfTask { @Override public void setParams(String params) { super.setParams(params); - maxNumSegments = Double.valueOf(params).intValue(); + maxNumSegments = (int)Double.parseDouble(params); } @Override diff --git a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java index dcce285383b..7a8e5f5f6e9 100644 --- a/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java +++ b/lucene/core/src/test/org/apache/lucene/util/fst/TestFSTs.java @@ -624,10 +624,10 @@ public class TestFSTs extends LuceneTestCase { int idx = 0; while (idx < args.length) { if (args[idx].equals("-prune")) { - prune = Integer.valueOf(args[1 + idx]); + prune = Integer.parseInt(args[1 + idx]); idx++; } else if (args[idx].equals("-limit")) { - limit = Integer.valueOf(args[1 + idx]); + limit = Integer.parseInt(args[1 + idx]); idx++; } else if (args[idx].equals("-utf8")) { inputMode = 0; diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java index a13e66fc21a..da3c20ed578 100644 --- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java +++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java @@ -1011,7 +1011,7 @@ public class TestBlockJoin extends LuceneTestCase { TopDocs childHits = new TopDocs(0, new ScoreDoc[0], 0f); for (ScoreDoc controlHit : controlHits.scoreDocs) { Document controlDoc = r.document(controlHit.doc); - int parentID = Integer.valueOf(controlDoc.get("parentID")); + int parentID = Integer.parseInt(controlDoc.get("parentID")); if (parentID != currentParentID) { assertEquals(childHitSlot, childHits.scoreDocs.length); currentParentID = parentID; diff --git a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java index 043141ac72a..f07793ace6d 100644 --- a/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java +++ b/lucene/misc/src/test/org/apache/lucene/search/TestDiversifiedTopDocsCollector.java @@ -392,7 +392,7 @@ public class TestDiversifiedTopDocsCollector extends LuceneTestCase { for (int i = 0; i < hitsOfThe60s.length; i++) { String cols[] = hitsOfThe60s[i].split("\t"); Record record = new Record(String.valueOf(i), cols[0], cols[1], cols[2], - Float.valueOf(cols[3])); + Float.parseFloat(cols[3])); parsedRecords.put(record.id, record); idField.setStringValue(record.id); yearField.setStringValue(record.year); diff --git a/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java b/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java index e0082932559..800859036eb 100644 --- a/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/function/TestValueSources.java @@ -123,9 +123,9 @@ public class TestValueSources extends LuceneTestCase { document.add(new StringField("id", doc[0], Field.Store.NO)); document.add(new SortedDocValuesField("id", new BytesRef(doc[0]))); document.add(new NumericDocValuesField("double", Double.doubleToRawLongBits(Double.parseDouble(doc[1])))); - document.add(new NumericDocValuesField("float", Float.floatToRawIntBits(Float.valueOf(doc[2])))); - document.add(new NumericDocValuesField("int", Integer.valueOf(doc[3]))); - document.add(new NumericDocValuesField("long", Long.valueOf(doc[4]))); + document.add(new NumericDocValuesField("float", Float.floatToRawIntBits(Float.parseFloat(doc[2])))); + document.add(new NumericDocValuesField("int", Integer.parseInt(doc[3]))); + document.add(new NumericDocValuesField("long", Long.parseLong(doc[4]))); document.add(new StringField("string", doc[5], Field.Store.NO)); document.add(new SortedDocValuesField("string", new BytesRef(doc[5]))); document.add(new TextField("text", doc[6], Field.Store.NO)); diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java index 3cfa7d0b8bf..cff9efa698e 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/classic/QueryParserBase.java @@ -837,7 +837,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer Query q; float fms = fuzzyMinSim; try { - fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue(); + fms = Float.parseFloat(fuzzySlop.image.substring(1)); } catch (Exception ignored) { } if(fms < 0.0f){ throw new ParseException("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !"); @@ -853,7 +853,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer int s = phraseSlop; // default if (fuzzySlop != null) { try { - s = Float.valueOf(fuzzySlop.image.substring(1)).intValue(); + s = (int)Float.parseFloat(fuzzySlop.image.substring(1)); } catch (Exception ignored) { } } @@ -865,7 +865,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer if (boost != null) { float f = (float) 1.0; try { - f = Float.valueOf(boost.image).floatValue(); + f = Float.parseFloat(boost.image); } catch (Exception ignored) { /* Should this be handled somehow? (defaults to "no boost", if diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java index ed0d67c84d9..8ba34a6ff4e 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java @@ -466,7 +466,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC if (boost != null) { float f = (float)1.0; try { - f = Float.valueOf(boost.image).floatValue(); + f = Float.parseFloat(boost.image); // avoid boosting null queries, such as those caused by stop words if (q != null) { q = new BoostQueryNode(q, f); @@ -542,7 +542,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC if (fuzzy) { float fms = defaultMinSimilarity; try { - fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue(); + fms = Float.parseFloat(fuzzySlop.image.substring(1)); } catch (Exception ignored) { } if(fms < 0.0f){ {if (true) throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS));} @@ -661,7 +661,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC if (fuzzySlop != null) { try { - phraseSlop = Float.valueOf(fuzzySlop.image.substring(1)).intValue(); + phraseSlop = (int)Float.parseFloat(fuzzySlop.image.substring(1)); q = new SlopQueryNode(q, phraseSlop); } catch (Exception ignored) { @@ -679,7 +679,7 @@ public class StandardSyntaxParser implements SyntaxParser, StandardSyntaxParserC if (boost != null) { float f = (float)1.0; try { - f = Float.valueOf(boost.image).floatValue(); + f = Float.parseFloat(boost.image); // avoid boosting null queries, such as those caused by stop words if (q != null) { q = new BoostQueryNode(q, f); diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj index 868b257b636..b53bab3c674 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj @@ -391,7 +391,7 @@ QueryNode Clause(CharSequence field) : { if (boost != null) { float f = (float)1.0; try { - f = Float.valueOf(boost.image).floatValue(); + f = Float.parseFloat(boost.image); // avoid boosting null queries, such as those caused by stop words if (q != null) { q = new BoostQueryNode(q, f); @@ -431,7 +431,7 @@ QueryNode Term(CharSequence field) : { if (fuzzy) { float fms = defaultMinSimilarity; try { - fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue(); + fms = Float.parseFloat(fuzzySlop.image.substring(1)); } catch (Exception ignored) { } if(fms < 0.0f){ throw new ParseException(new MessageImpl(QueryParserMessages.INVALID_SYNTAX_FUZZY_LIMITS)); @@ -472,7 +472,7 @@ QueryNode Term(CharSequence field) : { if (fuzzySlop != null) { try { - phraseSlop = Float.valueOf(fuzzySlop.image.substring(1)).intValue(); + phraseSlop = (int)Float.parseFloat(fuzzySlop.image.substring(1)); q = new SlopQueryNode(q, phraseSlop); } catch (Exception ignored) { @@ -488,7 +488,7 @@ QueryNode Term(CharSequence field) : { if (boost != null) { float f = (float)1.0; try { - f = Float.valueOf(boost.image).floatValue(); + f = Float.parseFloat(boost.image); // avoid boosting null queries, such as those caused by stop words if (q != null) { q = new BoostQueryNode(q, f); diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java index bd91f045dc9..f0f4b34f8f1 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.java @@ -481,7 +481,7 @@ public class QueryParser implements QueryParserConstants { weight = jj_consume_token(NUMBER); float f; try { - f = Float.valueOf(weight.image).floatValue(); + f = Float.parseFloat(weight.image); } catch (Exception floatExc) { {if (true) throw new ParseException(boostErrorMessage + weight.image + " (" + floatExc + ")");} } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj index d63189d73aa..857cca16df7 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/surround/parser/QueryParser.jj @@ -460,7 +460,7 @@ void OptionalWeights(SrndQuery q) : { ( weight= { float f; try { - f = Float.valueOf(weight.image).floatValue(); + f = Float.parseFloat(weight.image); } catch (Exception floatExc) { throw new ParseException(boostErrorMessage + weight.image + " (" + floatExc + ")"); } diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java index 82f7039f0be..1297ad48843 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/xml/builders/PointRangeQueryBuilder.java @@ -79,20 +79,20 @@ public class PointRangeQueryBuilder implements QueryBuilder { try { if (type.equalsIgnoreCase("int")) { return IntPoint.newRangeQuery(field, - (lowerTerm == null ? Integer.MIN_VALUE : Integer.valueOf(lowerTerm)), - (upperTerm == null ? Integer.MAX_VALUE : Integer.valueOf(upperTerm))); + (lowerTerm == null ? Integer.MIN_VALUE : Integer.parseInt(lowerTerm)), + (upperTerm == null ? Integer.MAX_VALUE : Integer.parseInt(upperTerm))); } else if (type.equalsIgnoreCase("long")) { return LongPoint.newRangeQuery(field, - (lowerTerm == null ? Long.MIN_VALUE : Long.valueOf(lowerTerm)), - (upperTerm == null ? Long.MAX_VALUE : Long.valueOf(upperTerm))); + (lowerTerm == null ? Long.MIN_VALUE : Long.parseLong(lowerTerm)), + (upperTerm == null ? Long.MAX_VALUE : Long.parseLong(upperTerm))); } else if (type.equalsIgnoreCase("double")) { return DoublePoint.newRangeQuery(field, - (lowerTerm == null ? Double.NEGATIVE_INFINITY : Double.valueOf(lowerTerm)), - (upperTerm == null ? Double.POSITIVE_INFINITY : Double.valueOf(upperTerm))); + (lowerTerm == null ? Double.NEGATIVE_INFINITY : Double.parseDouble(lowerTerm)), + (upperTerm == null ? Double.POSITIVE_INFINITY : Double.parseDouble(upperTerm))); } else if (type.equalsIgnoreCase("float")) { return FloatPoint.newRangeQuery(field, - (lowerTerm == null ? Float.NEGATIVE_INFINITY : Float.valueOf(lowerTerm)), - (upperTerm == null ? Float.POSITIVE_INFINITY : Float.valueOf(upperTerm))); + (lowerTerm == null ? Float.NEGATIVE_INFINITY : Float.parseFloat(lowerTerm)), + (upperTerm == null ? Float.POSITIVE_INFINITY : Float.parseFloat(upperTerm))); } else { throw new ParserException("type attribute must be one of: [long, int, double, float]"); } diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java index e8533e0a11d..34507941d58 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/classic/TestQueryParser.java @@ -193,7 +193,7 @@ public class TestQueryParser extends QueryParserTestBase { if(fuzzySlop.image.endsWith("€")) { float fms = fuzzyMinSim; try { - fms = Float.valueOf(fuzzySlop.image.substring(1, fuzzySlop.image.length()-1)).floatValue(); + fms = Float.parseFloat(fuzzySlop.image.substring(1, fuzzySlop.image.length()-1)); } catch (Exception ignored) { } float value = Float.parseFloat(termImage); return getRangeQuery(qfield, Float.toString(value-fms/2.f), Float.toString(value+fms/2.f), true, true); diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java index 5fa1523adfc..475688875bc 100644 --- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java +++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/xml/CoreParserTestIndexData.java @@ -52,7 +52,7 @@ class CoreParserTestIndexData implements Closeable { Document doc = new Document(); doc.add(LuceneTestCase.newTextField("date", date, Field.Store.YES)); doc.add(LuceneTestCase.newTextField("contents", content, Field.Store.YES)); - doc.add(new IntPoint("date3", Integer.valueOf(date))); + doc.add(new IntPoint("date3", Integer.parseInt(date))); writer.addDocument(doc); line = d.readLine(); } diff --git a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java index c3c2088de81..fa290228bbc 100644 --- a/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java +++ b/solr/contrib/analytics/src/java/org/apache/solr/analytics/util/RangeEndpointCalculator.java @@ -265,7 +265,7 @@ public abstract class RangeEndpointCalculator> { @Override public Float parseAndAddGap(Float value, String gap) { - return new Float(value.floatValue() + Float.valueOf(gap).floatValue()); + return new Float(value.floatValue() + Float.parseFloat(gap)); } } @@ -281,7 +281,7 @@ public abstract class RangeEndpointCalculator> { @Override public Double parseAndAddGap(Double value, String gap) { - return new Double(value.doubleValue() + Double.valueOf(gap).doubleValue()); + return new Double(value.doubleValue() + Double.parseDouble(gap)); } } @@ -297,7 +297,7 @@ public abstract class RangeEndpointCalculator> { @Override public Integer parseAndAddGap(Integer value, String gap) { - return new Integer(value.intValue() + Integer.valueOf(gap).intValue()); + return new Integer(value.intValue() + Integer.parseInt(gap)); } } @@ -313,7 +313,7 @@ public abstract class RangeEndpointCalculator> { @Override public Long parseAndAddGap(Long value, String gap) { - return new Long(value.longValue() + Long.valueOf(gap).longValue()); + return new Long(value.longValue() + Long.parseLong(gap)); } } diff --git a/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java b/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java index 0258c33022c..7545eacb18c 100644 --- a/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java +++ b/solr/contrib/dataimporthandler-extras/src/java/org/apache/solr/handler/dataimport/MailEntityProcessor.java @@ -843,7 +843,7 @@ public class MailEntityProcessor extends EntityProcessorBase { String val = context.getEntityAttribute(prop); if (val != null) { val = context.replaceTokens(val); - v = Integer.valueOf(val); + v = Integer.parseInt(val); } } catch (NumberFormatException e) { // do nothing diff --git a/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java b/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java index 1947f36167a..48dc82619e8 100644 --- a/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java +++ b/solr/contrib/velocity/src/java/org/apache/solr/response/PageTool.java @@ -38,7 +38,7 @@ public class PageTool { String rows = request.getParams().get("rows"); if (rows != null) { - results_per_page = new Integer(rows); + results_per_page = Integer.parseInt(rows); } //TODO: Handle group by results Object docs = response.getResponse(); diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java index a07496fcdf1..33e80913e68 100644 --- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java +++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java @@ -697,7 +697,7 @@ public class IndexFetcher { int indexCount = 1, confFilesCount = 1; if (props.containsKey(TIMES_INDEX_REPLICATED)) { - indexCount = Integer.valueOf(props.getProperty(TIMES_INDEX_REPLICATED)) + 1; + indexCount = Integer.parseInt(props.getProperty(TIMES_INDEX_REPLICATED)) + 1; } StringBuilder sb = readToStringBuilder(replicationTime, props.getProperty(INDEX_REPLICATED_AT_LIST)); props.setProperty(INDEX_REPLICATED_AT_LIST, sb.toString()); @@ -708,7 +708,7 @@ public class IndexFetcher { props.setProperty(CONF_FILES_REPLICATED, confFiles.toString()); props.setProperty(CONF_FILES_REPLICATED_AT, String.valueOf(replicationTime)); if (props.containsKey(TIMES_CONFIG_REPLICATED)) { - confFilesCount = Integer.valueOf(props.getProperty(TIMES_CONFIG_REPLICATED)) + 1; + confFilesCount = Integer.parseInt(props.getProperty(TIMES_CONFIG_REPLICATED)) + 1; } props.setProperty(TIMES_CONFIG_REPLICATED, String.valueOf(confFilesCount)); } @@ -717,7 +717,7 @@ public class IndexFetcher { if (!successfulInstall) { int numFailures = 1; if (props.containsKey(TIMES_FAILED)) { - numFailures = Integer.valueOf(props.getProperty(TIMES_FAILED)) + 1; + numFailures = Integer.parseInt(props.getProperty(TIMES_FAILED)) + 1; } props.setProperty(TIMES_FAILED, String.valueOf(numFailures)); props.setProperty(REPLICATION_FAILED_AT, String.valueOf(replicationTime)); diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java index e40b2c38311..4f6a408d533 100644 --- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -1075,7 +1075,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw String ss[] = s.split(","); List l = new ArrayList<>(); for (String s1 : ss) { - l.add(new Date(Long.valueOf(s1)).toString()); + l.add(new Date(Long.parseLong(s1)).toString()); } nl.add(key, l); } else { diff --git a/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java b/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java index 3ac73008471..c2348669b90 100644 --- a/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java +++ b/solr/core/src/java/org/apache/solr/handler/component/RangeFacetRequest.java @@ -659,7 +659,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase { @Override public Float parseAndAddGap(Float value, String gap) { - return new Float(value.floatValue() + Float.valueOf(gap).floatValue()); + return new Float(value.floatValue() + Float.parseFloat(gap)); } } @@ -677,7 +677,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase { @Override public Double parseAndAddGap(Double value, String gap) { - return new Double(value.doubleValue() + Double.valueOf(gap).doubleValue()); + return new Double(value.doubleValue() + Double.parseDouble(gap)); } } @@ -695,7 +695,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase { @Override public Integer parseAndAddGap(Integer value, String gap) { - return new Integer(value.intValue() + Integer.valueOf(gap).intValue()); + return new Integer(value.intValue() + Integer.parseInt(gap)); } } @@ -713,7 +713,7 @@ public class RangeFacetRequest extends FacetComponent.FacetBase { @Override public Long parseAndAddGap(Long value, String gap) { - return new Long(value.longValue() + Long.valueOf(gap).longValue()); + return new Long(value.longValue() + Long.parseLong(gap)); } } diff --git a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java index 84ffcb94568..cb3b1eedf05 100644 --- a/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java +++ b/solr/core/src/java/org/apache/solr/parser/SolrQueryParserBase.java @@ -623,7 +623,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder { } else if (fuzzy) { float fms = fuzzyMinSim; try { - fms = Float.valueOf(fuzzySlop.image.substring(1)).floatValue(); + fms = Float.parseFloat(fuzzySlop.image.substring(1)); } catch (Exception ignored) { } if(fms < 0.0f){ throw new SyntaxError("Minimum similarity for a FuzzyQuery has to be between 0.0f and 1.0f !"); @@ -644,7 +644,7 @@ public abstract class SolrQueryParserBase extends QueryBuilder { int s = phraseSlop; // default if (fuzzySlop != null) { try { - s = Float.valueOf(fuzzySlop.image.substring(1)).intValue(); + s = (int)Float.parseFloat(fuzzySlop.image.substring(1)); } catch (Exception ignored) { } } diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java index 276af5fffed..a50fa2c9811 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRange.java @@ -499,7 +499,7 @@ class FacetRangeProcessor extends FacetProcessor { } @Override public Float parseAndAddGap(Comparable value, String gap) { - return new Float(((Number)value).floatValue() + Float.valueOf(gap).floatValue()); + return new Float(((Number)value).floatValue() + Float.parseFloat(gap)); } } private static class DoubleCalc extends Calc { @@ -520,7 +520,7 @@ class FacetRangeProcessor extends FacetProcessor { } @Override public Double parseAndAddGap(Comparable value, String gap) { - return new Double(((Number)value).doubleValue() + Double.valueOf(gap).doubleValue()); + return new Double(((Number)value).doubleValue() + Double.parseDouble(gap)); } } private static class IntCalc extends Calc { @@ -532,7 +532,7 @@ class FacetRangeProcessor extends FacetProcessor { } @Override public Integer parseAndAddGap(Comparable value, String gap) { - return new Integer(((Number)value).intValue() + Integer.valueOf(gap).intValue()); + return new Integer(((Number)value).intValue() + Integer.parseInt(gap)); } } private static class LongCalc extends Calc { @@ -544,7 +544,7 @@ class FacetRangeProcessor extends FacetProcessor { } @Override public Long parseAndAddGap(Comparable value, String gap) { - return new Long(((Number)value).longValue() + Long.valueOf(gap).longValue()); + return new Long(((Number)value).longValue() + Long.parseLong(gap)); } } private static class DateCalc extends Calc { diff --git a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java index b642d8993ff..8ee5ff25f9e 100644 --- a/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java +++ b/solr/core/src/java/org/apache/solr/update/processor/TolerantUpdateProcessorFactory.java @@ -99,7 +99,7 @@ public class TolerantUpdateProcessorFactory extends UpdateRequestProcessorFactor Object maxErrorsObj = args.get(MAX_ERRORS_PARAM); if (maxErrorsObj != null) { try { - defaultMaxErrors = Integer.valueOf(maxErrorsObj.toString()); + defaultMaxErrors = Integer.parseInt(maxErrorsObj.toString()); } catch (Exception e) { throw new SolrException(ErrorCode.SERVER_ERROR, "Unnable to parse maxErrors parameter: " + maxErrorsObj, e); } diff --git a/solr/core/src/java/org/apache/solr/util/DateMathParser.java b/solr/core/src/java/org/apache/solr/util/DateMathParser.java index 643fde8f15a..2124d1d189c 100644 --- a/solr/core/src/java/org/apache/solr/util/DateMathParser.java +++ b/solr/core/src/java/org/apache/solr/util/DateMathParser.java @@ -381,7 +381,7 @@ public class DateMathParser { } int val = 0; try { - val = Integer.valueOf(ops[pos++]); + val = Integer.parseInt(ops[pos++]); } catch (NumberFormatException e) { throw new ParseException ("Not a Number: \"" + ops[pos-1] + "\"", pos-1); diff --git a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java index 93866005718..4445e07e1b0 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java +++ b/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java @@ -583,8 +583,8 @@ public class SolrPluginUtils { String[] fieldAndSlopVsBoost = caratPattern.split(s); String[] fieldVsSlop = tildePattern.split(fieldAndSlopVsBoost[0]); String field = fieldVsSlop[0]; - int slop = (2 == fieldVsSlop.length) ? Integer.valueOf(fieldVsSlop[1]) : defaultSlop; - Float boost = (1 == fieldAndSlopVsBoost.length) ? 1 : Float.valueOf(fieldAndSlopVsBoost[1]); + int slop = (2 == fieldVsSlop.length) ? Integer.parseInt(fieldVsSlop[1]) : defaultSlop; + float boost = (1 == fieldAndSlopVsBoost.length) ? 1 : Float.parseFloat(fieldAndSlopVsBoost[1]); FieldParams fp = new FieldParams(field,wordGrams,slop,boost); out.add(fp); } diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java index bb56a942ecf..9503ee45a2f 100644 --- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java +++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCloudSnapshots.java @@ -295,7 +295,7 @@ public class TestSolrCloudSnapshots extends SolrCloudTestCase { for(int i = 0 ; i < apiResult.size(); i++) { String commitName = apiResult.getName(i); String indexDirPath = (String)((NamedList)apiResult.get(commitName)).get(SolrSnapshotManager.INDEX_DIR_PATH); - long genNumber = Long.valueOf((String)((NamedList)apiResult.get(commitName)).get(SolrSnapshotManager.GENERATION_NUM)); + long genNumber = Long.parseLong((String)((NamedList)apiResult.get(commitName)).get(SolrSnapshotManager.GENERATION_NUM)); result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber)); } return result; diff --git a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java index da6dbac6231..7a9b0bb6c5f 100644 --- a/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java +++ b/solr/core/src/test/org/apache/solr/core/snapshots/TestSolrCoreSnapshots.java @@ -293,7 +293,7 @@ public class TestSolrCoreSnapshots extends SolrCloudTestCase { for(int i = 0 ; i < apiResult.size(); i++) { String commitName = apiResult.getName(i); String indexDirPath = (String)((NamedList)apiResult.get(commitName)).get("indexDirPath"); - long genNumber = Long.valueOf((String)((NamedList)apiResult.get(commitName)).get("generation")); + long genNumber = Long.parseLong((String)((NamedList)apiResult.get(commitName)).get("generation")); result.add(new SnapshotMetaData(commitName, indexDirPath, genNumber)); } return result; diff --git a/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java b/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java index 35bdec643bc..d11c9192090 100644 --- a/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java +++ b/solr/core/src/test/org/apache/solr/search/TestSolrFieldCacheMBean.java @@ -68,7 +68,7 @@ public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 { private void assertEntryListIncluded(boolean checkJmx) { SolrFieldCacheMBean mbean = new SolrFieldCacheMBean(); NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics(); - assert(new Integer(stats.get("entries_count").toString()) > 0); + assert(Integer.parseInt(stats.get("entries_count").toString()) > 0); assertNotNull(stats.get("total_size")); assertNotNull(stats.get("entry#0")); } @@ -76,7 +76,7 @@ public class TestSolrFieldCacheMBean extends SolrTestCaseJ4 { private void assertEntryListNotIncluded(boolean checkJmx) { SolrFieldCacheMBean mbean = new SolrFieldCacheMBean(); NamedList stats = checkJmx ? mbean.getStatisticsForJmx() : mbean.getStatistics(); - assert(new Integer(stats.get("entries_count").toString()) > 0); + assert(Integer.parseInt(stats.get("entries_count").toString()) > 0); assertNull(stats.get("total_size")); assertNull(stats.get("entry#0")); } diff --git a/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java b/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java index e3a8d7b2d64..f502f24ba2e 100644 --- a/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java +++ b/solr/core/src/test/org/apache/solr/search/mlt/CloudMLTQParserTest.java @@ -102,7 +102,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { int[] actualIds = new int[10]; int i = 0; for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); } assertArrayEquals(expectedIds, actualIds); @@ -117,7 +117,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { int[] actualIds = new int[solrDocuments.size()]; int i = 0; for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); } assertArrayEquals(expectedIds, actualIds); @@ -127,7 +127,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { actualIds = new int[solrDocuments.size()]; i = 0; for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); } System.out.println("DEBUG ACTUAL IDS 1: " + Arrays.toString(actualIds)); assertArrayEquals(expectedIds, actualIds); @@ -138,7 +138,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { actualIds = new int[solrDocuments.size()]; i = 0; for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); } System.out.println("DEBUG ACTUAL IDS 2: " + Arrays.toString(actualIds)); assertArrayEquals(expectedIds, actualIds); @@ -154,7 +154,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { int[] actualIds = new int[solrDocuments.size()]; int i = 0; for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); } assertArrayEquals(expectedIds, actualIds); @@ -184,7 +184,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { int[] actualIds = new int[solrDocuments.size()]; int i = 0; for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); } assertArrayEquals(expectedIds, actualIds); @@ -236,7 +236,7 @@ public class CloudMLTQParserTest extends SolrCloudTestCase { int i = 0; StringBuilder sb = new StringBuilder(); for (SolrDocument solrDocument : solrDocuments) { - actualIds[i++] = Integer.valueOf(String.valueOf(solrDocument.getFieldValue("id"))); + actualIds[i++] = Integer.parseInt(String.valueOf(solrDocument.getFieldValue("id"))); sb.append(actualIds[i-1]).append(", "); } assertArrayEquals(expectedIds, actualIds);