mirror of https://github.com/apache/lucene.git
LUCENE-7742: fix places where we were unboxing and then re-boxing according to FindBugs
This commit is contained in:
parent
124b505810
commit
716d43eca9
|
@ -256,6 +256,9 @@ Optimizations
|
|||
* LUCENE-7699: Query parsers now use span queries to produce more efficient
|
||||
phrase queries for multi-token synonyms. (Matt Webber via Jim Ferenczi)
|
||||
|
||||
* LUCENE-7742: Fix places where we were unboxing and then re-boxing
|
||||
according to FindBugs (Daniel Jelinski via Mike McCandless)
|
||||
|
||||
Build
|
||||
|
||||
* LUCENE-7653: Update randomizedtesting to version 2.5.0. (Dawid Weiss)
|
||||
|
|
|
@ -106,7 +106,7 @@ public class LatLonDocValuesField extends Field {
|
|||
result.append(name);
|
||||
result.append(':');
|
||||
|
||||
long currentValue = Long.valueOf((Long)fieldsData);
|
||||
long currentValue = (Long)fieldsData;
|
||||
result.append(decodeLatitude((int)(currentValue >> 32)));
|
||||
result.append(',');
|
||||
result.append(decodeLongitude((int)(currentValue & 0xFFFFFFFF)));
|
||||
|
|
|
@ -305,7 +305,7 @@ public class Geo3DDocValuesField extends Field {
|
|||
result.append(name);
|
||||
result.append(':');
|
||||
|
||||
long currentValue = Long.valueOf((Long)fieldsData);
|
||||
long currentValue = (Long)fieldsData;
|
||||
|
||||
result.append(decodeXValue(currentValue));
|
||||
result.append(',');
|
||||
|
|
|
@ -56,8 +56,9 @@ public class TikaLanguageIdentifierUpdateProcessor extends LanguageIdentifierUpd
|
|||
// FIXME: Hack - we get the distance from toString and calculate our own certainty score
|
||||
Double distance = Double.parseDouble(tikaSimilarityPattern.matcher(identifier.toString()).replaceFirst("$1"));
|
||||
// This formula gives: 0.02 => 0.8, 0.1 => 0.5 which is a better sweetspot than isReasonablyCertain()
|
||||
Double certainty = 1 - (5 * distance);
|
||||
certainty = (certainty < 0) ? 0 : certainty;
|
||||
Double certainty = 1 - (5 * distance);
|
||||
if (certainty < 0)
|
||||
certainty = 0d;
|
||||
DetectedLanguage language = new DetectedLanguage(identifier.getLanguage(), certainty);
|
||||
languages.add(language);
|
||||
log.debug("Language detected as "+language+" with a certainty of "+language.getCertainty()+" (Tika distance="+identifier.toString()+")");
|
||||
|
|
|
@ -222,7 +222,7 @@ public class RequestParams implements MapSerializable {
|
|||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return meta == null ? 0l : (Long) meta.get("v");
|
||||
return meta == null ? Long.valueOf(0l) : (Long) meta.get("v");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -103,10 +103,10 @@ class SolrEnumerator implements Enumerator<Object> {
|
|||
private Object getRealVal(Object val) {
|
||||
// Check if Double is really a Long
|
||||
if(val instanceof Double) {
|
||||
Double doubleVal = (double) val;
|
||||
double doubleVal = (double) val;
|
||||
//make sure that double has no decimals and fits within Long
|
||||
if(doubleVal % 1 == 0 && doubleVal >= Long.MIN_VALUE && doubleVal <= Long.MAX_VALUE) {
|
||||
return doubleVal.longValue();
|
||||
return (long)doubleVal;
|
||||
}
|
||||
return doubleVal;
|
||||
}
|
||||
|
|
|
@ -114,10 +114,10 @@ public abstract class NumericFieldType extends PrimitiveFieldType {
|
|||
if ((minVal == null || minVal.doubleValue() < 0d || minBits == minusZeroBits) &&
|
||||
(maxVal != null && (maxVal.doubleValue() < 0d || maxBits == minusZeroBits))) {
|
||||
query = numericDocValuesRangeQuery
|
||||
(fieldName, maxBits, (min == null ? negativeInfinityBits : minBits), maxInclusive, minInclusive, false);
|
||||
(fieldName, maxBits, (min == null ? Long.valueOf(negativeInfinityBits) : minBits), maxInclusive, minInclusive, false);
|
||||
} else { // If both max and min are positive, then issue range query
|
||||
query = numericDocValuesRangeQuery
|
||||
(fieldName, minBits, (max == null ? positiveInfinityBits : maxBits), minInclusive, maxInclusive, false);
|
||||
(fieldName, minBits, (max == null ? Long.valueOf(positiveInfinityBits) : maxBits), minInclusive, maxInclusive, false);
|
||||
}
|
||||
}
|
||||
return query;
|
||||
|
|
|
@ -601,7 +601,7 @@ public class Grouping {
|
|||
groupResult.add("matches", matches);
|
||||
if (totalCount == TotalCount.grouped) {
|
||||
Integer totalNrOfGroups = getNumberOfGroups();
|
||||
groupResult.add("ngroups", totalNrOfGroups == null ? 0 : totalNrOfGroups);
|
||||
groupResult.add("ngroups", totalNrOfGroups == null ? Integer.valueOf(0) : totalNrOfGroups);
|
||||
}
|
||||
maxMatches = Math.max(maxMatches, matches);
|
||||
return groupResult;
|
||||
|
|
|
@ -847,7 +847,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
|
|||
newVal = val.intValue();
|
||||
break;
|
||||
case LONG:
|
||||
newVal = val.longValue();
|
||||
newVal = val;
|
||||
break;
|
||||
case FLOAT:
|
||||
newVal = Float.intBitsToFloat(val.intValue());
|
||||
|
|
|
@ -119,7 +119,7 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor
|
|||
if (groupCount != null) {
|
||||
Integer existingGroupCount = rb.mergedGroupCounts.get(field);
|
||||
// Assuming groups don't cross shard boundary...
|
||||
rb.mergedGroupCounts.put(field, existingGroupCount != null ? existingGroupCount + groupCount : groupCount);
|
||||
rb.mergedGroupCounts.put(field, existingGroupCount != null ? Integer.valueOf(existingGroupCount + groupCount) : groupCount);
|
||||
}
|
||||
|
||||
final Collection<SearchGroup<BytesRef>> searchGroups = firstPhaseCommandResult.getSearchGroups();
|
||||
|
|
|
@ -83,7 +83,7 @@ enum AutorizationEditOperation {
|
|||
boolean indexSatisfied = index == null;
|
||||
for (int i = 0; i < permissions.size(); i++) {
|
||||
Map perm = permissions.get(i);
|
||||
Integer thisIdx = (int) perm.get("index");
|
||||
Integer thisIdx = (Integer) perm.get("index");
|
||||
if (thisIdx.equals(beforeIdx)) {
|
||||
beforeSatisfied = true;
|
||||
permissionsCopy.add(dataMap);
|
||||
|
|
|
@ -336,7 +336,7 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
|
|||
|
||||
if(boostedResults.size() == controlResults.size()) {
|
||||
for(int i=0; i<boostedResults.size(); i++) {
|
||||
if(!boostedResults.get(i).equals(controlResults.get(i).intValue())) {
|
||||
if(!boostedResults.get(i).equals(controlResults.get(i))) {
|
||||
throw new Exception("boosted results do not match control results, boostedResults size:"+boostedResults.toString()+", controlResults size:"+controlResults.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
|
|||
SolrDocumentList results = LEADER.query(params).getResults();
|
||||
assertEquals(numDocs, results.size());
|
||||
for (SolrDocument doc : results) {
|
||||
luceneDocids.add((int) doc.get("[docid]"));
|
||||
luceneDocids.add((Integer) doc.get("[docid]"));
|
||||
valuesList.add((Float) doc.get("inplace_updatable_float"));
|
||||
}
|
||||
log.info("Initial results: "+results);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class EqualsEvaluator extends BooleanEvaluator {
|
|||
return new BooleanChecker(){
|
||||
@Override
|
||||
public boolean test(Object left, Object right) {
|
||||
return (boolean)left.equals((boolean)right);
|
||||
return (boolean)left == (boolean)right;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class DocCollection extends ZkNodeProps implements Iterable<Slice> {
|
|||
this.replicationFactor = (Integer) verifyProp(props, REPLICATION_FACTOR);
|
||||
this.maxShardsPerNode = (Integer) verifyProp(props, MAX_SHARDS_PER_NODE);
|
||||
Boolean autoAddReplicas = (Boolean) verifyProp(props, AUTO_ADD_REPLICAS);
|
||||
this.autoAddReplicas = autoAddReplicas == null ? false : autoAddReplicas;
|
||||
this.autoAddReplicas = autoAddReplicas == null ? Boolean.FALSE : autoAddReplicas;
|
||||
Integer realtimeReplicas = (Integer) verifyProp(props, REALTIME_REPLICAS);
|
||||
this.realtimeReplicas = realtimeReplicas == null ? -1 : realtimeReplicas;
|
||||
if (this.realtimeReplicas != -1 && this.realtimeReplicas != 1) {
|
||||
|
|
|
@ -213,10 +213,10 @@ public class SolrParamTest extends LuceneTestCase {
|
|||
|
||||
// Get things with defaults
|
||||
assertEquals( pstr , params.get( "xxx", pstr ) );
|
||||
assertEquals( pbool.booleanValue() , params.getBool( "xxx", pbool ) );
|
||||
assertEquals( pbool , params.getBool( "xxx", pbool ) );
|
||||
assertEquals( pint.intValue() , params.getInt( "xxx", pint ) );
|
||||
assertEquals( pfloat.floatValue() , params.getFloat( "xxx", pfloat ), 0.1);
|
||||
assertEquals( pbool.booleanValue() , params.getFieldBool( "xxx", "bool", pbool ) );
|
||||
assertEquals( pbool , params.getFieldBool( "xxx", "bool", pbool ) );
|
||||
assertEquals( pint.intValue() , params.getFieldInt( "xxx", "int", pint ) );
|
||||
assertEquals( pfloat.floatValue() , params.getFieldFloat("xxx", "float", pfloat ), 0.1);
|
||||
assertEquals( pstr , params.getFieldParam("xxx", "str", pstr ) );
|
||||
|
|
Loading…
Reference in New Issue