Apache Solr open-source search software
SOLR-16405: Remove unneeded errorprone suppressions (#1001)
Kevin Risdene0f9d531bd02
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.javaindex fccd9109062..76e025c318f 100644--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java@@ -442,7 +442,6 @@ public class RecoveryStrategy implements Runnable, Closeable {/*** @return true if we have reached max attempts or should stop recovering for some other reason*/- @SuppressWarnings("NarrowCalculation")private boolean waitBetweenRecoveries(String coreName) {// lets pause for a moment and we need to try again...// TODO: we don't want to retry for some problems?@@ -473,7 +472,7 @@ public class RecoveryStrategy implements Runnable, Closeable {// Wait an exponential interval between retries, start at 4 seconds and work up to a minute.// Meanwhile we will check in 2s sub-intervals to see if we've been closed// Maximum loop count is 30 because we never want to wait longer than a minute (2s * 30 = 1m)- int loopCount = retries < 5 ? (int) Math.pow(2, retries) : 30;+ long loopCount = retries < 5 ? Math.round(Math.pow(2, retries)) : 30;if (log.isInfoEnabled()) {log.info("Wait [{}] seconds before trying to recover again (attempt={})",diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.javaindex 8b11d3ea879..7126ee7cba2 100644--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java@@ -1062,7 +1062,6 @@ public class ZkController implements Closeable {}}- @SuppressWarnings("NarrowCalculation")private void checkForExistingEphemeralNode() throws KeeperException, InterruptedException {if (zkRunOnly) {return;@@ -1094,7 +1093,7 @@ public class ZkController implements Closeable {}boolean deleted =- deletedLatch.await(zkClient.getZooKeeper().getSessionTimeout() * 2, TimeUnit.MILLISECONDS);+ deletedLatch.await(zkClient.getZooKeeper().getSessionTimeout() * 2L, TimeUnit.MILLISECONDS);if (!deleted) {throw new SolrException(ErrorCode.SERVER_ERROR,diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.javaindex 51eacafb648..bd99c649c3d 100644--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java@@ -1025,7 +1025,6 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw// TODO Should a failure retrieving any piece of info mark the overall request as a failure? Is// there a core set of values that are required to make a response here useful?/** Used for showing statistics and progress information. */- @SuppressWarnings("NarrowCalculation")private NamedList<Object> getReplicationDetails(SolrQueryResponse rsp, boolean showFollowerDetails) {NamedList<Object> details = new SimpleOrderedMap<>();@@ -1126,7 +1125,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAwcurrFileSizeDownloaded = (Long) currentFile.get("bytesDownloaded");bytesDownloaded += currFileSizeDownloaded;if (currFileSize > 0)- percentDownloaded = (currFileSizeDownloaded * 100) / currFileSize;+ percentDownloaded = (float) (currFileSizeDownloaded * 100) / currFileSize;}}follower.add("filesDownloaded", filesDownloaded);@@ -1146,7 +1145,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw((bytesToDownload - bytesDownloaded) * elapsed) / bytesDownloaded;float totalPercent = 0;long downloadSpeed = 0;- if (bytesToDownload > 0) totalPercent = (bytesDownloaded * 100) / bytesToDownload;+ if (bytesToDownload > 0) totalPercent = (float) (bytesDownloaded * 100) / bytesToDownload;if (elapsed > 0) downloadSpeed = (bytesDownloaded / elapsed);if (currFile != null) follower.add("currentFile", currFile);follower.add("currentFileSize", NumberUtils.readableSize(currFileSize));diff --git a/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java b/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.javaindex 10c5297c6f6..4ab96fbfd85 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/IndexSizeEstimator.java@@ -355,7 +355,6 @@ public class IndexSizeEstimator {result.put(NORMS, stats);}- @SuppressWarnings("LongDoubleConversion")private void estimatePoints(Map<String, Object> result) throws IOException {log.info("- estimating points...");Map<String, Map<String, Object>> stats = new HashMap<>();@@ -372,7 +371,8 @@ public class IndexSizeEstimator {(SummaryStatistics)perField.computeIfAbsent("lengths", s -> new MapWriterSummaryStatistics());lengthSummary.addValue(- values.size() * values.getBytesPerDimension() * values.getNumIndexDimensions());+ (double)+ (values.size() * values.getBytesPerDimension() * values.getNumIndexDimensions()));}}result.put(POINTS, stats);@@ -513,7 +513,6 @@ public class IndexSizeEstimator {result.put(TERMS, stats);}- @SuppressWarnings("LongDoubleConversion")private void estimateTermStats(String field, Terms terms, Map<String, Map<String, Object>> stats, boolean isSampling)throws IOException {@@ -550,12 +549,12 @@ public class IndexSizeEstimator {for (int i = 0; i < samplingStep; i++) {lengthSummary.addValue(term.length);docFreqSummary.addValue(termsEnum.docFreq());- totalFreqSummary.addValue(termsEnum.totalTermFreq());+ totalFreqSummary.addValue((double) termsEnum.totalTermFreq());}} else {lengthSummary.addValue(term.length);docFreqSummary.addValue(termsEnum.docFreq());- totalFreqSummary.addValue(termsEnum.totalTermFreq());+ totalFreqSummary.addValue((double) termsEnum.totalTermFreq());}if (terms.hasPayloads()) {postings = termsEnum.postings(postings, PostingsEnum.ALL);diff --git a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.javaindex 0682136cceb..a3d9bb66a6a 100644--- a/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java+++ b/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParser.java@@ -949,11 +949,8 @@ public class ExtendedDismaxQParser extends QParser {RANGE}- @SuppressWarnings("StaticAssignmentOfThrowable")- static final RuntimeException unknownField = new RuntimeException("UnknownField");-- static {- unknownField.fillInStackTrace();+ static RuntimeException unknownField() {+ return new RuntimeException("UnknownField");}/**@@ -1193,7 +1190,7 @@ public class ExtendedDismaxQParser extends QParser {if (exceptions) {FieldType ft = schema.getFieldTypeNoEx(field);if (ft == null && null == MagicFieldName.get(field)) {- throw unknownField;+ throw unknownField();}}@@ -1268,7 +1265,7 @@ public class ExtendedDismaxQParser extends QParser {if (exceptions) {FieldType ft = schema.getFieldTypeNoEx(field);if (ft == null && null == MagicFieldName.get(field)) {- throw unknownField;+ throw unknownField();}}return getQuery();diff --git a/solr/core/src/java/org/apache/solr/search/FunctionQParser.java b/solr/core/src/java/org/apache/solr/search/FunctionQParser.javaindex 686fe2ff7fc..03492cd5324 100644--- a/solr/core/src/java/org/apache/solr/search/FunctionQParser.java+++ b/solr/core/src/java/org/apache/solr/search/FunctionQParser.java@@ -82,13 +82,15 @@ public class FunctionQParser extends QParser {return parseMultipleSources;}- @SuppressWarnings("ErroneousBitwiseExpression")@Override+ @SuppressWarnings("ErroneousBitwiseExpression")public Query parse() throws SyntaxError {ValueSource vs = null;List<ValueSource> lst = null;for (; ; ) {+ // @SuppressWarnings("ErroneousBitwiseExpression") is needed since+ // FLAG_DEFAULT & ~FLAG_CONSUME_DELIMITER == 0ValueSource valsource = parseValueSource(FLAG_DEFAULT & ~FLAG_CONSUME_DELIMITER);sp.eatws();if (!parseMultipleSources) {@@ -337,6 +339,8 @@ public class FunctionQParser extends QParser {*/@SuppressWarnings("ErroneousBitwiseExpression")protected ValueSource parseValueSource(boolean doConsumeDelimiter) throws SyntaxError {+ // @SuppressWarnings("ErroneousBitwiseExpression") is needed since+ // FLAG_DEFAULT & ~FLAG_CONSUME_DELIMITER == 0return parseValueSource(doConsumeDelimiter? (FLAG_DEFAULT | FLAG_CONSUME_DELIMITER)diff --git a/solr/core/src/java/org/apache/solr/search/PointMerger.java b/solr/core/src/java/org/apache/solr/search/PointMerger.javaindex d50c3f3d7a2..bade14462c6 100644--- a/solr/core/src/java/org/apache/solr/search/PointMerger.java+++ b/solr/core/src/java/org/apache/solr/search/PointMerger.java@@ -237,7 +237,7 @@ public class PointMerger {count[pos] = 1;} else {// a new value we don't have room for- throw breakException;+ throw breakException();}}}@@ -299,7 +299,7 @@ public class PointMerger {count[pos] = 1;} else {// a new value we don't have room for- throw breakException;+ throw breakException();}}}@@ -361,7 +361,7 @@ public class PointMerger {count[pos] = 1;} else {// a new value we don't have room for- throw breakException;+ throw breakException();}}}@@ -423,7 +423,7 @@ public class PointMerger {count[pos] = 1;} else {// a new value we don't have room for- throw breakException;+ throw breakException();}}}@@ -453,6 +453,7 @@ public class PointMerger {}}- @SuppressWarnings("StaticAssignmentOfThrowable")- static BreakException breakException = new BreakException();+ static BreakException breakException() {+ return new BreakException();+ }}diff --git a/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java b/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.javaindex d68c5848368..086af5cc391 100644--- a/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java+++ b/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java@@ -327,9 +327,9 @@ public abstract class DocValuesAcc extends SlotAcc {double[] result;double initialValue;- @SuppressWarnings("LongDoubleConversion")public DoubleSortedSetDVAcc(- FacetContext fcontext, SchemaField sf, int numSlots, long initialValue) throws IOException {+ FacetContext fcontext, SchemaField sf, int numSlots, double initialValue)+ throws IOException {super(fcontext, sf, numSlots);result = new double[numSlots];this.initialValue = initialValue;diff --git a/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java b/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.javaindex 38e87ec6dfa..41d7f2a938e 100644--- a/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java+++ b/solr/core/src/java/org/apache/solr/search/facet/UnInvertedField.java@@ -169,17 +169,16 @@ public class UnInvertedField extends DocTermOrds {maxTermCounts[termNum] = docFreq;}- @SuppressWarnings("NarrowCalculation")public long memSize() {// can cache the mem size since it shouldn't changeif (memsz != 0) return memsz;long sz = super.ramBytesUsed();sz += 8 * 8 + 32; // local fields- sz += bigTerms.size() * 64;+ sz += bigTerms.size() * 64L;for (TopTerm tt : bigTerms.values()) {sz += tt.memSize();}- if (maxTermCounts != null) sz += maxTermCounts.length * 4;+ if (maxTermCounts != null) sz += maxTermCounts.length * 4L;memsz = sz;return sz;}diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.javaindex 500353b0e94..b9b1dc6d66c 100644--- a/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java+++ b/solr/core/src/java/org/apache/solr/servlet/SolrRequestParsers.java@@ -608,13 +608,12 @@ public class SolrRequestParsers {static class MultipartRequestParser implements SolrRequestParser {private final MultipartConfigElement multipartConfigElement;- @SuppressWarnings("NarrowCalculation")public MultipartRequestParser(int uploadLimitKB) {multipartConfigElement =new MultipartConfigElement(null, // temp dir (null=default)-1, // maxFileSize (-1=none)- uploadLimitKB * 1024, // maxRequestSize+ uploadLimitKB * 1024L, // maxRequestSize100 * 1024); // fileSizeThreshold after which will go to disk}diff --git a/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java b/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.javaindex 811fdf014ae..8fd64b63c72 100644--- a/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java+++ b/solr/core/src/java/org/apache/solr/uninverting/DocTermOrds.java@@ -168,19 +168,18 @@ public class DocTermOrds implements Accountable {// TODO: Why is indexedTermsArray not part of this?/** Returns total bytes used. */- @SuppressWarnings("NarrowCalculation")@Overridepublic long ramBytesUsed() {// can cache the mem size since it shouldn't changeif (memsz != 0) return memsz;long sz = 8 * 8 + 32; // local fields- if (index != null) sz += index.length * 4;+ if (index != null) sz += index.length * 4L;if (tnums != null) {for (byte[] arr : tnums) if (arr != null) sz += arr.length;}if (indexedTermsArray != null) {// assume 8 byte references?- sz += 8 + 8 + 8 + 8 + (indexedTermsArray.length << 3) + sizeOfIndexedStrings;+ sz += 8 + 8 + 8 + 8 + ((long) indexedTermsArray.length << 3) + sizeOfIndexedStrings;}memsz = sz;return sz;diff --git a/solr/core/src/java/org/apache/solr/uninverting/FieldCacheImpl.java b/solr/core/src/java/org/apache/solr/uninverting/FieldCacheImpl.javaindex 0629b79a4de..91d549ef8a9 100644--- a/solr/core/src/java/org/apache/solr/uninverting/FieldCacheImpl.java+++ b/solr/core/src/java/org/apache/solr/uninverting/FieldCacheImpl.java@@ -894,13 +894,12 @@ public class FieldCacheImpl implements FieldCache {}}- @SuppressWarnings("NarrowCalculation")@Overridepublic long ramBytesUsed() {return bytes.ramBytesUsed()+ termOrdToBytesOffset.ramBytesUsed()+ docToTermOrd.ramBytesUsed()- + 3 * RamUsageEstimator.NUM_BYTES_OBJECT_REF+ + 3L * RamUsageEstimator.NUM_BYTES_OBJECT_REF+ Integer.BYTES;}@@ -1108,12 +1107,11 @@ public class FieldCacheImpl implements FieldCache {};}- @SuppressWarnings("NarrowCalculation")@Overridepublic long ramBytesUsed() {return bytes.ramBytesUsed()+ docToOffset.ramBytesUsed()- + 2 * RamUsageEstimator.NUM_BYTES_OBJECT_REF;+ + 2L * RamUsageEstimator.NUM_BYTES_OBJECT_REF;}@Overridediff --git a/solr/core/src/java/org/apache/solr/update/processor/IgnoreLargeDocumentProcessorFactory.java b/solr/core/src/java/org/apache/solr/update/processor/IgnoreLargeDocumentProcessorFactory.javaindex 5a76315097e..fea5fe6b225 100644--- a/solr/core/src/java/org/apache/solr/update/processor/IgnoreLargeDocumentProcessorFactory.java+++ b/solr/core/src/java/org/apache/solr/update/processor/IgnoreLargeDocumentProcessorFactory.java@@ -140,14 +140,13 @@ public class IgnoreLargeDocumentProcessorFactory extends UpdateRequestProcessorFreturn primitiveEstimate(obj, 0L);}- @SuppressWarnings("NarrowCalculation")private static long primitiveEstimate(Object obj, long def) {Class<?> clazz = obj.getClass();if (clazz.isPrimitive()) {return primitiveSizes.get(clazz);}if (obj instanceof String) {- return ((String) obj).length() * Character.BYTES;+ return (long) ((String) obj).length() * Character.BYTES;}return def;}diff --git a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.javaindex e7a3a0bac1a..2bee753a3ea 100644--- a/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java+++ b/solr/core/src/java/org/apache/solr/util/ConcurrentLRUCache.java@@ -153,12 +153,11 @@ public class ConcurrentLRUCache<K, V> implements Cache<K, V>, Accountable {setRunCleanupThread(runCleanupThread);}- @SuppressWarnings("NarrowCalculation")public ConcurrentLRUCache(int size, int lowerWatermark) {this(size,lowerWatermark,- (int) Math.floor((lowerWatermark + size) / 2),+ (int) Math.floor((lowerWatermark + size) / 2.0),(int) Math.ceil(0.75 * size),false,false,@@ -646,7 +645,7 @@ public class ConcurrentLRUCache<K, V> implements Cache<K, V>, Accountable {myMaxSize = maxSz;}- @SuppressWarnings({"unchecked", "NarrowCalculation"})+ @SuppressWarnings("unchecked")Iterable<CacheEntry<K, V>> getValues() {return (Iterable) Collections.unmodifiableCollection(Arrays.asList(heap));}@@ -839,7 +838,6 @@ public class ConcurrentLRUCache<K, V> implements Cache<K, V>, Accountable {}public static class Stats implements Accountable {- @SuppressWarnings("NarrowCalculation")private static final long RAM_BYTES_USED =// accounts for field refsRamUsageEstimator.shallowSizeOfInstance(Stats.class)@@ -848,7 +846,7 @@ public class ConcurrentLRUCache<K, V> implements Cache<K, V>, Accountable {6* (RamUsageEstimator.NUM_BYTES_ARRAY_HEADER+ RamUsageEstimator.primitiveSizes.get(long.class)- + 2+ + 2L* (RamUsageEstimator.NUM_BYTES_OBJECT_REF+ RamUsageEstimator.primitiveSizes.get(long.class)))+diff --git a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java b/solr/core/src/java/org/apache/solr/util/SimplePostTool.javaindex abbeb11a520..4d051235d88 100644--- a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java+++ b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java@@ -572,14 +572,13 @@ public class SimplePostTool {** @return number of files posted*/- @SuppressWarnings("NarrowCalculation")int postFiles(File[] files, OutputStream out, String type) {int filesPosted = 0;for (File srcFile : files) {try {if (!srcFile.isFile() || srcFile.isHidden()) continue;postFile(srcFile, out, type);- Thread.sleep(delay * 1000);+ Thread.sleep(delay * 1000L);filesPosted++;} catch (InterruptedException e) {throw new RuntimeException(e);@@ -659,7 +658,6 @@ public class SimplePostTool {* @param out output stream to write to* @return number of pages crawled on this level and below*/- @SuppressWarnings("NarrowCalculation")protected int webCrawl(int level, OutputStream out) {int numPages = 0;LinkedHashSet<URI> stack = backlog.get(level);@@ -687,9 +685,9 @@ public class SimplePostTool {appendParam(solrUrl.toString(),"literal.id="- + URLEncoder.encode(url.toString(), "UTF-8")+ + URLEncoder.encode(url.toString(), UTF_8)+ "&literal.url="- + URLEncoder.encode(url.toString(), "UTF-8")));+ + URLEncoder.encode(url.toString(), UTF_8)));ByteBuffer content = result.content;boolean success =postData(@@ -700,7 +698,7 @@ public class SimplePostTool {postUrl);if (success) {info("POSTed web resource " + url + " (depth: " + level + ")");- Thread.sleep(delay * 1000);+ Thread.sleep(delay * 1000L);numPages++;// Pull links from HTML pages onlyif (recursive > level && result.contentType.equals("text/html")) {diff --git a/solr/core/src/java/org/apache/solr/util/TestInjection.java b/solr/core/src/java/org/apache/solr/util/TestInjection.javaindex 8145a8684d3..80f0cd7f56b 100644--- a/solr/core/src/java/org/apache/solr/util/TestInjection.java+++ b/solr/core/src/java/org/apache/solr/util/TestInjection.java@@ -236,7 +236,6 @@ public class TestInjection {return true;}- @SuppressWarnings("NarrowCalculation")public static boolean injectRandomDelayInCoreCreation() {if (randomDelayInCoreCreation != null) {Random rand = random();@@ -249,7 +248,7 @@ public class TestInjection {int delay = rand.nextInt(randomDelayMaxInCoreCreationInSec);log.info("Inject random core creation delay of {}s", delay);try {- Thread.sleep(delay * 1000);+ Thread.sleep(delay * 1000L);} catch (InterruptedException e) {Thread.currentThread().interrupt();}@@ -258,7 +257,6 @@ public class TestInjection {return true;}- @SuppressWarnings("NarrowCalculation")public static boolean injectNonGracefullClose(CoreContainer cc) {if (cc.isShutDown() && nonGracefullClose != null) {Random rand = random();diff --git a/solr/core/src/java/org/apache/solr/util/hll/BigEndianAscendingWordDeserializer.java b/solr/core/src/java/org/apache/solr/util/hll/BigEndianAscendingWordDeserializer.javaindex 8bd68f0745e..87405cd0e4b 100644--- a/solr/core/src/java/org/apache/solr/util/hll/BigEndianAscendingWordDeserializer.java+++ b/solr/core/src/java/org/apache/solr/util/hll/BigEndianAscendingWordDeserializer.java@@ -48,7 +48,6 @@ class BigEndianAscendingWordDeserializer implements IWordDeserializer {* than or equal to zero.* @param bytes the byte array containing the serialized words. Cannot be <code>null</code>.*/- @SuppressWarnings("NarrowCalculation")public BigEndianAscendingWordDeserializer(final int wordLength, final int bytePadding, final byte[] bytes) {if ((wordLength < 1) || (wordLength > 64)) {@@ -66,7 +65,7 @@ class BigEndianAscendingWordDeserializer implements IWordDeserializer {this.bytePadding = bytePadding;final int dataBytes = (bytes.length - bytePadding);- final long dataBits = (dataBytes * BITS_PER_BYTE);+ final long dataBits = ((long) dataBytes * BITS_PER_BYTE);this.wordCount = (int) (dataBits / wordLength);diff --git a/solr/core/src/java/org/apache/solr/util/hll/HLL.java b/solr/core/src/java/org/apache/solr/util/hll/HLL.javaindex 918f8ce9655..e825d0e6769 100644--- a/solr/core/src/java/org/apache/solr/util/hll/HLL.java+++ b/solr/core/src/java/org/apache/solr/util/hll/HLL.java@@ -153,7 +153,6 @@ public class HLL implements Cloneable {* @param type the type in the promotion hierarchy which this instance should start at. This* cannot be <code>null</code>.*/- @SuppressWarnings("NarrowCalculation")public HLL(final int log2m,final int regwidth,@@ -233,7 +232,7 @@ public class HLL implements Cloneable {// TODO improve this cutoff to include the cost overhead of Java// members/objectsfinal int largestPow2LessThanCutoff =- (int) NumberUtil.log2((this.m * this.regwidth) / this.shortWordLength);+ (int) NumberUtil.log2((float) (this.m * this.regwidth) / this.shortWordLength);this.sparseThreshold = (1 << largestPow2LessThanCutoff);}diff --git a/solr/core/src/java/org/apache/solr/util/hll/HLLUtil.java b/solr/core/src/java/org/apache/solr/util/hll/HLLUtil.javaindex e5fbd429a70..9a5eb5082d4 100644--- a/solr/core/src/java/org/apache/solr/util/hll/HLLUtil.java+++ b/solr/core/src/java/org/apache/solr/util/hll/HLLUtil.java@@ -91,11 +91,10 @@ final class HLLUtil {* expected. This must be greater than zero.* @return a register size in bits (i.e. <code>log2(log2(n))</code>)*/- @SuppressWarnings("LongDoubleConversion")public static int registerBitSize(final long expectedUniqueElements) {return Math.max(HLL.MINIMUM_REGWIDTH_PARAM,- (int) Math.ceil(NumberUtil.log2(NumberUtil.log2(expectedUniqueElements))));+ (int) Math.ceil(NumberUtil.log2(NumberUtil.log2((double) expectedUniqueElements))));}// ========================================================================diff --git a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.javaindex 16713301caa..8c186b0e38a 100644--- a/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java+++ b/solr/core/src/java/org/apache/solr/util/stats/MetricUtils.java@@ -634,7 +634,6 @@ public class MetricUtils {}// some snapshots represent time in ns, other snapshots represent raw values (eg. chunk size)- @SuppressWarnings("LongDoubleConversion")static void addSnapshot(MapWriter.EntryWriter ew,Snapshot snapshot,@@ -646,8 +645,8 @@ public class MetricUtils {ew.putNoEx(k, v);}};- filter.accept((ms ? MIN_MS : MIN), nsToMs(ms, snapshot.getMin()));- filter.accept((ms ? MAX_MS : MAX), nsToMs(ms, snapshot.getMax()));+ filter.accept((ms ? MIN_MS : MIN), nsToMs(ms, (double) snapshot.getMin()));+ filter.accept((ms ? MAX_MS : MAX), nsToMs(ms, (double) snapshot.getMax()));filter.accept((ms ? MEAN_MS : MEAN), nsToMs(ms, snapshot.getMean()));filter.accept((ms ? MEDIAN_MS : MEDIAN), nsToMs(ms, snapshot.getMedian()));filter.accept((ms ? STDDEV_MS : STDDEV), nsToMs(ms, snapshot.getStdDev()));diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.javaindex c403a1387e1..bedcfeab03e 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java@@ -270,11 +270,10 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {** @return <code>0</code> if a commit was done, else <code>itersSinceLastCommit + 1</code>*/- @SuppressWarnings("NarrowCalculation")private static int maybeCommit(final Random rand, final int itersSinceLastCommit, final int numIters)throws IOException, SolrServerException {- final float threshold = itersSinceLastCommit / numIters;+ final float threshold = (float) itersSinceLastCommit / numIters;if (rand.nextFloat() < threshold) {log.info("COMMIT");assertEquals(0, getRandClient(rand).commit().getStatus());diff --git a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.javaindex 55fddced18c..510021eba79 100644--- a/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java+++ b/solr/core/src/test/org/apache/solr/cloud/TestStressCloudBlindAtomicUpdates.java@@ -177,7 +177,6 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {CLIENTS.clear();}- @SuppressWarnings("NarrowCalculation")@Beforeprivate void clearCloudCollection() throws Exception {TestInjection.reset();@@ -191,7 +190,7 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {0,CLOUD_CLIENT.query(params("q", "*:*")).getResults().getNumFound());- final int injectionPercentage = (int) Math.ceil(atLeast(1) / 2);+ final int injectionPercentage = (int) Math.ceil((float) atLeast(1) / 2);testInjection = usually() ? "false:0" : ("true:" + injectionPercentage);}diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.javaindex 6ce5bc0522d..762cac06d45 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java@@ -1453,7 +1453,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {checkForSingleIndex(followerJetty, true);}- @SuppressWarnings("NarrowCalculation")@Testpublic void testRateLimitedReplication() throws Exception {@@ -1494,7 +1493,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {}float approximateTimeInSeconds =- Math.round(totalBytes / 1024 / 1024 / 0.1); // maxWriteMBPerSec=0.1 in solrconfig+ Math.round((float) totalBytes / 1024 / 1024 / 0.1); // maxWriteMBPerSec=0.1 in solrconfig// Start again and replicate the datauseFactory(null);diff --git a/solr/core/src/test/org/apache/solr/handler/component/TestDistributedStatsComponentCardinality.java b/solr/core/src/test/org/apache/solr/handler/component/TestDistributedStatsComponentCardinality.javaindex f2486ea1629..25542df1234 100644--- a/solr/core/src/test/org/apache/solr/handler/component/TestDistributedStatsComponentCardinality.java+++ b/solr/core/src/test/org/apache/solr/handler/component/TestDistributedStatsComponentCardinality.java@@ -107,7 +107,6 @@ public class TestDistributedStatsComponentCardinality extends BaseDistributedSeacommit();}- @SuppressWarnings("NarrowCalculation")public void test() throws Exception {buildIndex();@@ -141,9 +140,9 @@ public class TestDistributedStatsComponentCardinality extends BaseDistributedSea// MINIMUM_LOG2M_PARAM is just too absurdly small to give anything remotely close to the// theoretically expected relative error.//- // So we have to use a slightly higher lower bound on what log2m values we randomly test+ // So we have to use a higher lower bound on what log2m values we randomly testfinal int log2m =- TestUtil.nextInt(random(), 2 + HLL.MINIMUM_LOG2M_PARAM, HLL.MAXIMUM_LOG2M_PARAM);+ TestUtil.nextInt(random(), 13 + HLL.MINIMUM_LOG2M_PARAM, HLL.MAXIMUM_LOG2M_PARAM);// use max regwidth to try and prevent hash collisions from introducing problemsfinal int regwidth = HLL.MAXIMUM_REGWIDTH_PARAM;@@ -174,20 +173,24 @@ public class TestDistributedStatsComponentCardinality extends BaseDistributedSeafor (String f : STAT_FIELDS) {// check the relative error of the estimate returned against the known truth-final double relErr = expectedRelativeError(log2m);final long estimate = stats.get(f).getCardinality();+ final double actualError = ((double) Math.abs(numMatches - estimate) / numMatches);assertTrue(f- + ": relativeErr="+ + ": log2m="+ + log2m+ + ", relativeErr="+ relErr+ + ", actualError="+ + actualError+ ", estimate="+ estimate+ ", real="+ numMatches+ ", p="+ p,- (Math.abs(numMatches - estimate) / numMatches) < relErr);+ actualError < relErr);}}@@ -262,12 +265,11 @@ public class TestDistributedStatsComponentCardinality extends BaseDistributedSea}/** Returns the (max) expected relative error according ot the HLL algorithm docs */- @SuppressWarnings("LongDoubleConversion")private static double expectedRelativeError(final int log2m) {- final long m = 1 << log2m;+ final long m = 1L << log2m;// theoretical error is 1.04D * sqrt(m)// fudge slightly to account for variance in random data- return 1.1D / Math.sqrt(m);+ return 1.10D * (1.04D / Math.sqrt((double) m));}/**diff --git a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.javaindex 5271f82cee0..308a4c12488 100644--- a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java+++ b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery32.java@@ -402,14 +402,13 @@ public class TestNumericRangeQuery32 extends SolrTestCase {dir.close();}- @SuppressWarnings("NarrowCalculation")private void testRangeSplit(int precisionStep) throws Exception {String field = "ascfield" + precisionStep;// 10 random testsint num = TestUtil.nextInt(random(), 10, 20);for (int i = 0; i < num; i++) {- int lower = (int) (random().nextDouble() * noDocs - noDocs / 2);- int upper = (int) (random().nextDouble() * noDocs - noDocs / 2);+ int lower = (int) (random().nextDouble() * noDocs - noDocs / 2.0);+ int upper = (int) (random().nextDouble() * noDocs - noDocs / 2.0);if (lower > upper) {int a = lower;lower = upper;diff --git a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.javaindex 2f638ba5b35..f495a751386 100644--- a/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java+++ b/solr/core/src/test/org/apache/solr/legacy/TestNumericRangeQuery64.java@@ -51,7 +51,6 @@ public class TestNumericRangeQuery64 extends SolrTestCase {private static IndexReader reader = null;private static IndexSearcher searcher = null;- @SuppressWarnings("NarrowCalculation")@BeforeClasspublic static void beforeClass() throws Exception {noDocs = atLeast(4096);@@ -426,14 +425,13 @@ public class TestNumericRangeQuery64 extends SolrTestCase {dir.close();}- @SuppressWarnings("NarrowCalculation")private void testRangeSplit(int precisionStep) throws Exception {String field = "ascfield" + precisionStep;// 10 random testsint num = TestUtil.nextInt(random(), 10, 20);for (int i = 0; i < num; i++) {- long lower = (long) (random().nextDouble() * noDocs - noDocs / 2);- long upper = (long) (random().nextDouble() * noDocs - noDocs / 2);+ long lower = (long) (random().nextDouble() * noDocs - noDocs / 2.0);+ long upper = (long) (random().nextDouble() * noDocs - noDocs / 2.0);if (lower > upper) {long a = lower;lower = upper;diff --git a/solr/core/src/test/org/apache/solr/request/TestFaceting.java b/solr/core/src/test/org/apache/solr/request/TestFaceting.javaindex 0d452227d39..f0e8a47eb11 100644--- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java+++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java@@ -77,7 +77,6 @@ public class TestFaceting extends SolrTestCaseJ4 {req = null;}- @SuppressWarnings("UnnecessaryLongToIntConversion")void doTermEnum(int size) throws Exception {// System.out.println("doTermEnum size=" + size);close();@@ -110,7 +109,7 @@ public class TestFaceting extends SolrTestCaseJ4 {}assertEquals(br != null, rnum < size);if (rnum < size) {- assertEquals(rnum, (int) te.ord());+ assertEquals(rnum, te.ord());assertEquals(s, te.term().utf8ToString());}}@@ -130,7 +129,7 @@ public class TestFaceting extends SolrTestCaseJ4 {te.seekExact((long) rnum);BytesRef br = te.term();assertNotNull(br);- assertEquals(rnum, (int) te.ord());+ assertEquals(rnum, te.ord());assertEquals(s, te.term().utf8ToString());}}diff --git a/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java b/solr/core/src/test/org/apache/solr/schema/DocValuesTest.javaindex 9973b32bdf0..ed826cb5e30 100644--- a/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java+++ b/solr/core/src/test/org/apache/solr/schema/DocValuesTest.java@@ -22,6 +22,7 @@ import java.util.ArrayList;import java.util.Arrays;import java.util.Date;import java.util.List;+import java.util.Objects;import java.util.function.Function;import java.util.function.Supplier;import org.apache.lucene.index.DocValuesType;@@ -993,7 +994,6 @@ public class DocValuesTest extends SolrTestCaseJ4 {"//result/doc[2]/str[@name='id'][.=4]");}- @SuppressWarnings("BoxedPrimitiveEquality")@Testpublic void testFloatAndDoubleRangeQueryRandom() {@@ -1111,10 +1111,10 @@ public class DocValuesTest extends SolrTestCaseJ4 {if ((minInclusive && minSortable <= valSortable|| !minInclusive && minSortable < valSortable- || (min.equals("*") && val == negativeInfinity[i]))+ || (min.equals("*") && Objects.equals(val, negativeInfinity[i])))&& (maxInclusive && maxSortable >= valSortable|| !maxInclusive && maxSortable > valSortable- || (max.equals("*") && val == positiveInfinity[i]))) {+ || (max.equals("*") && Objects.equals(val, positiveInfinity[i])))) {counter++;tests.add("//result/doc[" + counter + "]/str[@name='id'][.=" + (k + 1) + "]");tests.add("//result/doc[" + counter + "]/float[@name='score'][.=1.0]");diff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.javaindex d11ffe2817f..3a50ba15daf 100644--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.java+++ b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/LongValueStream.java@@ -47,9 +47,8 @@ public interface LongValueStream extends AnalyticsValueStream {*/public abstract static class AbstractLongValueStream implements CastingLongValueStream {@Override- @SuppressWarnings("LongDoubleConversion")public void streamDoubles(DoubleConsumer cons) {- streamLongs((long val) -> cons.accept(val));+ streamLongs((long val) -> cons.accept((double) val));}@Overridediff --git a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.javaindex ec87284c1e4..df641a7188b 100644--- a/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java+++ b/solr/modules/analytics/src/java/org/apache/solr/analytics/value/constant/ConstantLongValue.java@@ -70,9 +70,8 @@ public class ConstantLongValue extends ConstantValue implements CastingLongValue}@Override- @SuppressWarnings("LongDoubleConversion")public void streamDoubles(DoubleConsumer cons) {- cons.accept(value);+ cons.accept((double) value);}@Overridediff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.javaindex 5bc00e9c741..77a38c1342b 100644--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/function/mapping/LogFunctionTest.java@@ -122,7 +122,6 @@ public class LogFunctionTest extends SolrTestCaseJ4 {assertTrue(func.exists());}- @SuppressWarnings("LongDoubleConversion")@Testpublic void oneMultiOneSingleValueParameterTest() {TestLongValueStream base = new TestLongValueStream();@@ -154,9 +153,9 @@ public class LogFunctionTest extends SolrTestCaseJ4 {val.setValue(4.56F).setExists(true);Iterator<Double> values =Arrays.asList(- Math.log(4.56F) / Math.log(4L),- Math.log(4.56F) / Math.log(123L),- Math.log(4.56F) / Math.log(2L))+ Math.log(4.56F) / Math.log(4.0D),+ Math.log(4.56F) / Math.log(123.0D),+ Math.log(4.56F) / Math.log(2.0D)).iterator();func.streamDoubles(value -> {@@ -166,7 +165,6 @@ public class LogFunctionTest extends SolrTestCaseJ4 {assertFalse(values.hasNext());}- @SuppressWarnings("LongDoubleConversion")@Testpublic void oneSingleOneMultiValueParameterTest() {TestDoubleValue base = new TestDoubleValue();@@ -198,9 +196,9 @@ public class LogFunctionTest extends SolrTestCaseJ4 {val.setValues(2L, 50L, 3L);Iterator<Double> values =Arrays.asList(- Math.log(2L) / Math.log(4.56F),- Math.log(50L) / Math.log(4.56F),- Math.log(3L) / Math.log(4.56F))+ Math.log(2.0D) / Math.log(4.56F),+ Math.log(50.0D) / Math.log(4.56F),+ Math.log(3.0D) / Math.log(4.56F)).iterator();func.streamDoubles(value -> {diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.javaindex 7a98f06fdba..668bfb630fe 100644--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.java+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyExpressionTest.java@@ -127,7 +127,6 @@ public class LegacyExpressionTest extends LegacyAbstractAnalyticsTest {assertEquals(getRawResponse(), Math.pow(meanResult, countResult), result, 0.0);}- @SuppressWarnings("LongDoubleConversion")@Testpublic void negateTest() throws Exception {double sumResult = (Double) getStatResult("nr", "sum", VAL_TYPE.DOUBLE);@@ -136,10 +135,9 @@ public class LegacyExpressionTest extends LegacyAbstractAnalyticsTest {long countResult = ((Long) getStatResult("nr", "count", VAL_TYPE.LONG));long lresult = (Long) getStatResult("nr", "c", VAL_TYPE.LONG);- assertEquals(getRawResponse(), -1 * countResult, lresult, 0.0);+ assertEquals(getRawResponse(), -1 * countResult, lresult);}- @SuppressWarnings("LongDoubleConversion")@Testpublic void absoluteValueTest() throws Exception {double sumResult = (Double) getStatResult("avr", "sum", VAL_TYPE.DOUBLE);@@ -148,13 +146,13 @@ public class LegacyExpressionTest extends LegacyAbstractAnalyticsTest {long countResult = ((Long) getStatResult("avr", "count", VAL_TYPE.LONG));long lresult = (Long) getStatResult("avr", "c", VAL_TYPE.LONG);- assertEquals(getRawResponse(), countResult, lresult, 0.0);+ assertEquals(getRawResponse(), countResult, lresult);}@Testpublic void constantNumberTest() throws Exception {int result = (Integer) getStatResult("cnr", "c8", VAL_TYPE.INTEGER);- assertEquals(getRawResponse(), 8, result, 0.0);+ assertEquals(getRawResponse(), 8, result);double dresult = (Double) getStatResult("cnr", "c10", VAL_TYPE.DOUBLE);assertEquals(getRawResponse(), 10.0, dresult, 0.0);diff --git a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.java b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.javaindex 7e898a887b1..8d6291a1a72 100644--- a/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.java+++ b/solr/modules/analytics/src/test/org/apache/solr/analytics/legacy/expression/LegacyFunctionTest.java@@ -33,7 +33,6 @@ public class LegacyFunctionTest extends LegacyAbstractAnalyticsTest {public static final int NUM_LOOPS = 100;@BeforeClass- @SuppressWarnings("LongDoubleConversion")public static void beforeClass() throws Exception {initCore("solrconfig-analytics.xml", "schema-analytics.xml");h.update("<delete><query>*:*</query></delete>");@@ -54,7 +53,7 @@ public class LegacyFunctionTest extends LegacyAbstractAnalyticsTest {double div_if = (double) i / f;double div_ld = (double) l / d;double pow_if = Math.pow(i, f);- double pow_ld = Math.pow(l, d);+ double pow_ld = Math.pow((double) l, d);int neg_i = i * -1;long neg_l = l * -1;String dm_2y = (1802 + j % DATE) + "-06-30T23:59:59Z";diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.javaindex 01a8873653c..fe543a2d396 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/graph/GatherNodesStream.java@@ -607,7 +607,6 @@ public class GatherNodesStream extends TupleStream implements Expressible {}}- @SuppressWarnings("NarrowCalculation")private String[] getTenSecondWindow(int size, int lag, String start) {try {List<String> windowList = new ArrayList<>();@@ -619,17 +618,17 @@ public class GatherNodesStream extends TupleStream implements Expressible {++i;Instant windowInstant =size > 0- ? instant.plus(10 * i, ChronoUnit.SECONDS)- : instant.minus(10 * i, ChronoUnit.SECONDS);+ ? instant.plus(10L * i, ChronoUnit.SECONDS)+ : instant.minus(10L * i, ChronoUnit.SECONDS);String windowString = windowInstant.toString();windowString = windowString.substring(0, 18) + "0Z";windowList.add(windowString);}List<String> laggedWindow = windowList.subList(lag, windowList.size());- return laggedWindow.toArray(new String[laggedWindow.size()]);+ return laggedWindow.toArray(new String[0]);} catch (ParseException e) {- log.warn("Unparseable date:{}", String.valueOf(start));+ log.warn("Unparseable date: {}", start);return new String[0];}}diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java b/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.javaindex 34f786dd840..3cfe43a56c8 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/CompositeIdRouter.java@@ -213,7 +213,6 @@ public class CompositeIdRouter extends HashBasedRouter {}@Override- @SuppressWarnings("NarrowCalculation")public List<Range> partitionRange(int partitions, Range range) {int min = range.min;int max = range.max;@@ -236,7 +235,7 @@ public class CompositeIdRouter extends HashBasedRouter {// With default bits==16, one would need to create more than 4000 shards before this// becomes false by default.int mask = 0x0000ffff;- boolean round = rangeStep >= (1 << bits) * 16;+ boolean round = rangeStep >= (1L << bits) * 16;while (end < max) {targetEnd = targetStart + rangeStep;diff --git a/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java b/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.javaindex dc7a0be53be..5429c9b936b 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/FastJavaBinDecoder.java@@ -611,7 +611,7 @@ public class FastJavaBinDecoder implements DataEntry.FastDecoder {@Overridepublic Object readObject(StreamCodec codec, EntryImpl entry) {- return Integer.valueOf((int) entry.numericVal);+ return (int) entry.numericVal;}},_SLONG(SLONG, UPPER_3_BITS, DataEntry.Type.LONG) {@@ -621,9 +621,8 @@ public class FastJavaBinDecoder implements DataEntry.FastDecoder {}@Override- @SuppressWarnings("UnnecessaryLongToIntConversion")public Object readObject(StreamCodec codec, EntryImpl entry) {- return Long.valueOf((int) entry.numericVal);+ return entry.numericVal;}},_ARR(ARR, UPPER_3_BITS, DataEntry.Type.ENTRY_ITER) {diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.javaindex 9c9c4801869..15f094b595c 100644--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java@@ -3020,7 +3020,6 @@ public class StreamingTest extends SolrCloudTestCase {return true;}- @SuppressWarnings("UnnecessaryLongToIntConversion")protected boolean assertGroupOrder(Tuple tuple, int... ids) {@SuppressWarnings({"rawtypes"})List group = (List) tuple.get("tuples");@@ -3028,8 +3027,8 @@ public class StreamingTest extends SolrCloudTestCase {for (int val : ids) {@SuppressWarnings({"rawtypes"})Map t = (Map) group.get(i);- Long tip = (Long) t.get("id");- assertEquals(val, tip.intValue());+ int tip = (int) t.get("id");+ assertEquals(val, tip);++i;}return true;diff --git a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.javaindex 718d1a0218e..f0a50f7dd41 100644--- a/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/ContentStreamTest.java@@ -35,16 +35,14 @@ import org.apache.solr.core.SolrResourceLoader;/** Tests {@link ContentStream} such as "stream.file". */public class ContentStreamTest extends SolrTestCaseJ4 {- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testStringStream() throws IOException {String input = "aads ghaskdgasgldj asl sadg ajdsg &jag # @ hjsakg hsakdg hjkas s";ContentStreamBase stream = new ContentStreamBase.StringStream(input);- assertEquals(input.length(), stream.getSize().intValue());- assertEquals(input, IOUtils.toString(stream.getStream(), "UTF-8"));+ assertEquals(input.length(), stream.getSize().longValue());+ assertEquals(input, IOUtils.toString(stream.getStream(), StandardCharsets.UTF_8));assertEquals(input, IOUtils.toString(stream.getReader()));}- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testFileStream() throws IOException {File file = new File(createTempDir().toFile(), "README");try (SolrResourceLoader srl = new SolrResourceLoader(Paths.get("").toAbsolutePath());@@ -60,7 +58,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {InputStreamReader isr =new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8);Reader r = stream.getReader()) {- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());// Test the code that sets content based on < being the 1st characterassertEquals("application/xml", stream.getContentType());assertTrue(IOUtils.contentEquals(fis, s));@@ -68,7 +66,6 @@ public class ContentStreamTest extends SolrTestCaseJ4 {}}- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testFileStreamGZIP() throws IOException {File file = new File(createTempDir().toFile(), "README.gz");@@ -87,7 +84,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {FileInputStream fis2 = new FileInputStream(file);GZIPInputStream zis2 = new GZIPInputStream(fis2);Reader r = stream.getReader()) {- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());// Test the code that sets content based on < being the 1st characterassertEquals("application/xml", stream.getContentType());assertTrue(IOUtils.contentEquals(isr, r));@@ -95,7 +92,6 @@ public class ContentStreamTest extends SolrTestCaseJ4 {}}- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testURLStream() throws IOException {File file = new File(createTempDir().toFile(), "README");@@ -121,13 +117,12 @@ public class ContentStreamTest extends SolrTestCaseJ4 {//assertEquals("text/html", stream.getContentType());assertTrue(IOUtils.contentEquals(fis2, s));- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());assertTrue(IOUtils.contentEquals(isr, r));- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());}}- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testURLStreamGZIP() throws IOException {File file = new File(createTempDir().toFile(), "README.gz");@@ -151,11 +146,10 @@ public class ContentStreamTest extends SolrTestCaseJ4 {assertEquals("application/xml", stream.getContentType());assertTrue(IOUtils.contentEquals(isr, r));assertTrue(IOUtils.contentEquals(zis2, s));- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());}}- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testURLStreamCSVGZIPExtention() throws IOException {File file = new File(createTempDir().toFile(), "README.CSV.gz");@@ -179,11 +173,10 @@ public class ContentStreamTest extends SolrTestCaseJ4 {assertEquals("text/csv", stream.getContentType());assertTrue(IOUtils.contentEquals(isr, r));assertTrue(IOUtils.contentEquals(zis2, s));- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());}}- @SuppressWarnings("UnnecessaryLongToIntConversion")public void testURLStreamJSONGZIPExtention() throws IOException {File file = new File(createTempDir().toFile(), "README.json.gzip");@@ -207,7 +200,7 @@ public class ContentStreamTest extends SolrTestCaseJ4 {assertEquals("application/json", stream.getContentType());assertTrue(IOUtils.contentEquals(isr, r));assertTrue(IOUtils.contentEquals(zis2, s));- assertEquals(file.length(), stream.getSize().intValue());+ assertEquals(file.length(), stream.getSize().longValue());}}}diff --git a/solr/solrj/src/test/org/apache/solr/common/util/TestHash.java b/solr/solrj/src/test/org/apache/solr/common/util/TestHash.javaindex 90a3bd17439..7f8a50c244f 100644--- a/solr/solrj/src/test/org/apache/solr/common/util/TestHash.java+++ b/solr/solrj/src/test/org/apache/solr/common/util/TestHash.java@@ -67,7 +67,6 @@ public class TestHash extends SolrTestCase {// test that the hash of the UTF-16 encoded Java String is equal to the hash of the unicode code// points- @SuppressWarnings("UnnecessaryLongToIntConversion")void tstEquiv(int[] utf32, int len) {int seed = 100;StringBuilder sb = new StringBuilder();@@ -77,8 +76,8 @@ public class TestHash extends SolrTestCase {assertEquals(hash, hash2);int hash3 = Hash.lookup3ycs(sb, 0, sb.length(), seed);assertEquals(hash, hash3);- long hash4 = Hash.lookup3ycs64(sb, 0, sb.length(), seed);- assertEquals((int) hash4, hash);+ int hash4 = (int) Hash.lookup3ycs64(sb, 0, sb.length(), seed);+ assertEquals(hash4, hash);}public void testHash() {