vthacker commented on pull request #1816:
URL: https://github.com/apache/lucene-solr/pull/1816#issuecomment-686220411
Here is the complete list of warnings/errors that this tool gives us for
lucene-core
```
~/apache-work/lucene-solr (solr_core_errorprone) $ gradlew -p lucene/core/
compileJava
> Task :lucene:core:compileJava
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/Sort.java:180:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (fields[i] != rewrittenSortFields[i]) {
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (!Objects.equals(fields[i], rewrittenSortFields[i])) {'
or 'if (!fields[i].equals(rewrittenSortFields[i])) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/Sort.java:185:
warning: [UnnecessaryParentheses] These grouping parentheses are unnecessary;
it is unlikely the code will be misinterpreted without them
return (changed) ? new Sort(rewrittenSortFields) : this;
^
(see https://errorprone.info/bugpattern/UnnecessaryParentheses)
Did you mean 'return changed ? new Sort(rewrittenSortFields) : this;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java:690:
warning: [ModifiedButNotUsed] A collection or proto builder was created, but
its values were never accessed.
final List<C> collectedCollectors = new ArrayList<>();
^
(see https://errorprone.info/bugpattern/ModifiedButNotUsed)
Did you mean to remove this line or to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java:756:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
for (Query rewrittenQuery = query.rewrite(reader); rewrittenQuery !=
query;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'for (Query rewrittenQuery = query.rewrite(reader);
!Objects.equals(rewrittenQuery, query);' or 'for (Query rewrittenQuery =
query.rewrite(reader); !rewrittenQuery.equals(query);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:98:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public Similarity() {}
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected Similarity() {}'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:111:
warning: [EscapedEntity] HTML entities in @code/@literal tags will appear
literally in the rendered javadoc.
* {@code Long.compareUnsigned(n1, n2) > 0} then
^
(see https://errorprone.info/bugpattern/EscapedEntity)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:112:
warning: [EscapedEntity] HTML entities in @code/@literal tags will appear
literally in the rendered javadoc.
* {@code SimScorer.score(freq, n1) <= SimScorer.score(freq, n2)}
^
(see https://errorprone.info/bugpattern/EscapedEntity)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:157:
warning: [EscapedEntity] HTML entities in @code/@literal tags will appear
literally in the rendered javadoc.
* {@code freq1 > freq2}, then {@code score(freq1, norm) >=
^
(see https://errorprone.info/bugpattern/EscapedEntity)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:157:
warning: [EscapedEntity] HTML entities in @code/@literal tags will appear
literally in the rendered javadoc.
* {@code freq1 > freq2}, then {@code score(freq1, norm) >=
^
(see https://errorprone.info/bugpattern/EscapedEntity)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:162:
warning: [EscapedEntity] HTML entities in @code/@literal tags will appear
literally in the rendered javadoc.
* {@code Long.compareUnsigned(norm1, norm2) > 0} then
^
(see https://errorprone.info/bugpattern/EscapedEntity)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/similarities/Similarity.java:163:
warning: [EscapedEntity] HTML entities in @code/@literal tags will appear
literally in the rendered javadoc.
* {@code score(freq, norm1) <= score(freq, norm2)} for any legal
^
(see https://errorprone.info/bugpattern/EscapedEntity)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/automaton/RunAutomaton.java:206:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object obj) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java:502:
warning: [InconsistentHashCode] hashCode includes the fields [numWords], which
equals does not. Two instances of this class could compare equal, but have
different hashCodes, which violates the hashCode contract.
public int hashCode() {
^
(see https://errorprone.info/bugpattern/InconsistentHashCode)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java:189:
warning: [MissingOverride] set implements method in BitSet; expected @Override
public void set(int index) {
^
(see https://errorprone.info/bugpattern/MissingOverride)
Did you mean '@Override public void set(int index) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/FieldInvertState.java:94:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (this.attributeSource != attributeSource) {
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (!Objects.equals(this.attributeSource, attributeSource))
{' or 'if (!this.attributeSource.equals(attributeSource)) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/AttributeSource.java:437:
warning: [BadImport] Importing nested classes/static methods/static fields
with commonly-used names can make code harder to read, because it may not be
clear from the context exactly which type is being referred to. Qualifying the
name with that of the containing class can make the code clearer.
for (Entry<Class<? extends Attribute>, AttributeImpl> entry :
this.attributes.entrySet()) {
^
(see https://errorprone.info/bugpattern/BadImport)
Did you mean 'for (Map.Entry<Class<? extends Attribute>, AttributeImpl>
entry : this.attributes.entrySet()) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/AttributeFactory.java:104:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public StaticImplementationAttributeFactory(AttributeFactory delegate,
Class<A> clazz) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected
StaticImplementationAttributeFactory(AttributeFactory delegate, Class<A> clazz)
{'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/AttributeFactory.java:118:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object other) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean 'if (!(other instanceof
StaticImplementationAttributeFactory))'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/search/FieldComparator.java:148:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public NumericComparator(String field, T missingValue) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected NumericComparator(String field, T missingValue) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/automaton/CompiledAutomaton.java:478:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object obj) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java:97:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public Analyzer() {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected Analyzer() {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java:109:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public Analyzer(ReuseStrategy reuseStrategy) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected Analyzer(ReuseStrategy reuseStrategy) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java:370:
warning: [ProtectedMembersInFinalClass] Make members of final classes
package-private: source, sink
protected final Consumer<Reader> source;
^
(see https://errorprone.info/bugpattern/ProtectedMembersInFinalClass)
Did you mean 'final Consumer<Reader> source;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/analysis/Analyzer.java:445:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public ReuseStrategy() {}
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected ReuseStrategy() {}'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/CloseableThreadLocal.java:58:
warning: [ThreadLocalUsage] ThreadLocals should be stored in static fields
private ThreadLocal<WeakReference<T>> t = new ThreadLocal<>();
^
(see https://errorprone.info/bugpattern/ThreadLocalUsage)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/CloseableThreadLocal.java:97:
warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not
safe: if the field is ever updated, different threads may end up locking on
different objects.
synchronized(hardRefs) {
^
(see https://errorprone.info/bugpattern/SynchronizeOnNonFinalField)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/CloseableThreadLocal.java:111:
warning: [SynchronizeOnNonFinalField] Synchronizing on non-final fields is not
safe: if the field is ever updated, different threads may end up locking on
different objects.
synchronized(hardRefs) {
^
(see https://errorprone.info/bugpattern/SynchronizeOnNonFinalField)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/store/IOContext.java:113:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object obj) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java:199:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
* 2; // hash tables need to be oversized to avoid collisions,
assume 2x capacity
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean '2L * NUM_BYTES_OBJECT_REF'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java:362:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (query != root) {
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (!Objects.equals(query, root)) {' or 'if
(!query.equals(root)) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/RamUsageEstimator.java:376:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (query == root) {
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (Objects.equals(query, root)) {' or 'if
(query.equals(root)) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocValuesUpdate.java:102:
warning: [InconsistentCapitalization] Found the field 'docIDUpto' with the
same name as the parameter 'docIDUpTo' but with different capitalization.
private BinaryDocValuesUpdate(Term term, String field, BytesRef value,
int docIDUpTo) {
^
(see https://errorprone.info/bugpattern/InconsistentCapitalization)
Did you mean 'private BinaryDocValuesUpdate(Term term, String field,
BytesRef value, int docIDUpto) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocValuesUpdate.java:159:
warning: [InconsistentCapitalization] Found the field 'docIDUpto' with the
same name as the parameter 'docIDUpTo' but with different capitalization.
private NumericDocValuesUpdate(Term term, String field, long value, int
docIDUpTo, boolean hasValue) {
^
(see https://errorprone.info/bugpattern/InconsistentCapitalization)
Did you mean 'private NumericDocValuesUpdate(Term term, String field, long
value, int docIDUpto, boolean hasValue) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocValuesUpdate.java:73:
warning: [NarrowingCompoundAssignment] Compound assignments from long to int
hide lossy casts
sizeInBytes += valueSizeInBytes();
^
(see https://errorprone.info/bugpattern/NarrowingCompoundAssignment)
Did you mean 'sizeInBytes = (int) (sizeInBytes + valueSizeInBytes());'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocValuesUpdate.java:96:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
private static final long RAW_VALUE_SIZE_IN_BYTES =
NUM_BYTES_ARRAY_HEADER + 2*Integer.BYTES + NUM_BYTES_OBJECT_REF;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'private static final long RAW_VALUE_SIZE_IN_BYTES = (long)
NUM_BYTES_ARRAY_HEADER + 2*Integer.BYTES + NUM_BYTES_OBJECT_REF;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:401:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
private final LinkedList<MergePolicy.OneMerge> pendingMerges = new
LinkedList<>();
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2206:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
if (pendingMerges.contains(merge) ||
runningMerges.contains(merge)) {
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2337:
warning: [MissingOverride] getMergingSegments implements method in
MergeContext; expected @Override
public synchronized Set<SegmentCommitInfo> getMergingSegments() {
^
(see https://errorprone.info/bugpattern/MissingOverride)
Did you mean '@Override public synchronized Set<SegmentCommitInfo>
getMergingSegments() {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2348:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
if (pendingMerges.size() == 0) {
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2352:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
MergePolicy.OneMerge merge = pendingMerges.removeFirst();
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2364:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
return pendingMerges.size() != 0;
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2632:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
pendingMerges.clear();
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:2679:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
while (pendingMerges.size() > 0 || runningMerges.size() > 0) {
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:3237:
warning: [UndefinedEquals] Collection does not have well-defined equals
behavior.
assert copiedFiles.equals(newInfoPerCommit.files()): "copiedFiles=" +
copiedFiles + " vs " + newInfoPerCommit.files();
^
(see https://errorprone.info/bugpattern/UndefinedEquals)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:3587:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
boolean removed = pendingMerges.remove(merge);
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4437:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
pendingMerges.add(merge);
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4440:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
infoStream.message("IW", "add merge to pendingMerges: " +
segString(merge.segments) + " [total " + pendingMerges.size() + " pending]");
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4476:
warning: [NarrowingCompoundAssignment] Compound assignments from double to
long hide lossy casts
merge.estimatedMergeBytes += info.sizeInBytes() * (1.0 - delRatio);
^
(see https://errorprone.info/bugpattern/NarrowingCompoundAssignment)
Did you mean 'merge.estimatedMergeBytes = (long)
(merge.estimatedMergeBytes + info.sizeInBytes() * (1.0 - delRatio));'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4581:
warning: [JdkObsolete] Date has a bad API that leads to bugs; prefer
java.time.Instant or LocalDate.
diagnostics.put("timestamp", Long.toString(new Date().getTime()));
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4581:
warning: [JdkObsolete] Date has a bad API that leads to bugs; prefer
java.time.Instant or LocalDate.
diagnostics.put("timestamp", Long.toString(new Date().getTime()));
^
(see https://errorprone.info/bugpattern/JdkObsolete)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4699:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (reader != wrappedReader) { // if we don't have a wrapped
reader we won't preserve any soft-deletes
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (!Objects.equals(reader, wrappedReader)) {' or 'if
(!reader.equals(wrappedReader)) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4746:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
assert mergeState.segmentInfo == merge.info.info;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'assert Objects.equals(mergeState.segmentInfo,
merge.info.info);' or 'assert mergeState.segmentInfo.equals(merge.info.info);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:4969:
warning: [WaitNotInLoop] Because of spurious wakeups, wait(long) must always
be called in a loop
wait(1000);
^
(see https://errorprone.info/bugpattern/WaitNotInLoop)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java:5900:
warning: [MissingOverride] toString overrides method in Object; expected
@Override
public String toString() {
^
(see https://errorprone.info/bugpattern/MissingOverride)
Did you mean '@Override public String toString() {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/MergeState.java:245:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public DocMap() {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected DocMap() {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java:185:
warning: [BadImport] Importing nested classes/static methods/static fields
with commonly-used names can make code harder to read, because it may not be
clear from the context exactly which type is being referred to. Qualifying the
name with that of the containing class can make the code clearer.
Set<Entry<PauseReason,AtomicLong>> entries = pauseTimesNS.entrySet();
^
(see https://errorprone.info/bugpattern/BadImport)
Did you mean 'Set<Map.Entry<PauseReason,AtomicLong>> entries =
pauseTimesNS.entrySet();'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/MergePolicy.java:561:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public MergePolicy() {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected MergePolicy() {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java:513:
warning: [LockNotBeforeTry] Prefer locking *immediately* before the try block
which releases the lock to avoid the possibility of any intermediate statements
throwing.
globalBufferLock.lock();
^
(see https://errorprone.info/bugpattern/LockNotBeforeTry)
Did you mean to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java:56:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public Allocator(int blockSize) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected Allocator(int blockSize) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java:235:
warning: [MutablePublicArray] Non-empty arrays are mutable, so this `public
static final` array is not a constant and can be modified by clients of this
class. Prefer an ImmutableList, or provide an accessor method that returns a
defensive copy.
public final static int[] NEXT_LEVEL_ARRAY = {1, 2, 3, 4, 5, 6, 7, 8, 9,
9};
^
(see https://errorprone.info/bugpattern/MutablePublicArray)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/ByteBlockPool.java:240:
warning: [MutablePublicArray] Non-empty arrays are mutable, so this `public
static final` array is not a constant and can be modified by clients of this
class. Prefer an ImmutableList, or provide an accessor method that returns a
defensive copy.
public final static int[] LEVEL_SIZE_ARRAY = {5, 14, 20, 30, 40, 40, 80,
80, 120, 200};
^
(see https://errorprone.info/bugpattern/MutablePublicArray)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:336:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
assert flushPending.get() == Boolean.TRUE;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'assert Objects.equals(flushPending.get(), Boolean.TRUE);' or
'assert flushPending.get().equals(Boolean.TRUE);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:596:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
return flushPending.get() == Boolean.TRUE;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'return Objects.equals(flushPending.get(), Boolean.TRUE);' or
'return flushPending.get().equals(Boolean.TRUE);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:623:
warning: [NonAtomicVolatileUpdate] This update of a volatile variable is
non-atomic
lastCommittedBytesUsed += delta;
^
(see https://errorprone.info/bugpattern/NonAtomicVolatileUpdate)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java:665:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
return hasFlushed.get() == Boolean.TRUE;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'return Objects.equals(hasFlushed.get(), Boolean.TRUE);' or
'return hasFlushed.get().equals(Boolean.TRUE);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/packed/PackedInts.java:148:
warning: [ImmutableEnumChecker] enums should be immutable: 'Format' has
non-final field 'id'
public int id;
^
(see https://errorprone.info/bugpattern/ImmutableEnumChecker)
Did you mean 'public final int id;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/LongsRef.java:75:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
final long end = offset + length;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'final long end = (long) offset + length;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/LongsRef.java:109:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
final long end = offset + length;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'final long end = (long) offset + length;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/SegmentCommitInfo.java:392:
warning: [BadImport] Importing nested classes/static methods/static fields
with commonly-used names can make code harder to read, because it may not be
clear from the context exactly which type is being referred to. Qualifying the
name with that of the containing class can make the code clearer.
for (Entry<Integer,Set<String>> e : dvUpdatesFiles.entrySet()) {
^
(see https://errorprone.info/bugpattern/BadImport)
Did you mean 'for (Map.Entry<Integer,Set<String>> e :
dvUpdatesFiles.entrySet()) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java:583:
warning: [BadImport] Importing nested classes/static methods/static fields
with commonly-used names can make code harder to read, because it may not be
clear from the context exactly which type is being referred to. Qualifying the
name with that of the containing class can make the code clearer.
for (Entry<Integer,Set<String>> e : dvUpdatesFiles.entrySet()) {
^
(see https://errorprone.info/bugpattern/BadImport)
Did you mean 'for (Map.Entry<Integer,Set<String>> e :
dvUpdatesFiles.entrySet()) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java:443:
warning: [Finally] If you return or throw from a finally, then values returned
or thrown from the try-catch block will be ignored. Consider using
try-with-resources instead.
throw IOUtils.rethrowAlways(priorE);
^
(see https://errorprone.info/bugpattern/Finally)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/SegmentInfos.java:672:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public FindSegmentsFile(Directory directory) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected FindSegmentsFile(Directory directory) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/IndexFileDeleter.java:80:
warning: [AlmostJavadoc] This comment contains Javadoc or HTML tags, but isn't
started with a double asterisk (/**); is it meant to be Javadoc?
final class IndexFileDeleter implements Closeable {
^
(see https://errorprone.info/bugpattern/AlmostJavadoc)
Did you mean '/**'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/store/Lock.java:48:
warning: [MissingOverride] close implements method in Closeable; expected
@Override
public abstract void close() throws IOException;
^
(see https://errorprone.info/bugpattern/MissingOverride)
Did you mean '@Override public abstract void close() throws IOException;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java:141:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
assert newReader != oldReader;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'assert !Objects.equals(newReader, oldReader);' or 'assert
!newReader.equals(oldReader);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java:154:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
assert newReader != oldReader;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'assert !Objects.equals(newReader, oldReader);' or 'assert
!newReader.equals(oldReader);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java:236:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
assert newReader != oldReader;
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'assert !Objects.equals(newReader, oldReader);' or 'assert
!newReader.equals(oldReader);'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/ReadersAndUpdates.java:280:
warning: [BadImport] Importing nested classes/static methods/static fields
with commonly-used names can make code harder to read, because it may not be
clear from the context exactly which type is being referred to. Qualifying the
name with that of the containing class can make the code clearer.
for (Entry<String,List<DocValuesFieldUpdates>> ent :
pendingDVUpdates.entrySet()) {
^
(see https://errorprone.info/bugpattern/BadImport)
Did you mean 'for (Map.Entry<String,List<DocValuesFieldUpdates>> ent :
pendingDVUpdates.entrySet()) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/ReadersAndUpdates.java:429:
warning: [ProtectedMembersInFinalClass] Make members of final classes
package-private: <init>
protected MergedDocValues(DocValuesInstance onDiskDocValues,
DocValuesInstance updateDocValues, DocValuesFieldUpdates.Iterator
updateIterator) {
^
(see https://errorprone.info/bugpattern/ProtectedMembersInFinalClass)
Did you mean 'MergedDocValues(DocValuesInstance onDiskDocValues,
DocValuesInstance updateDocValues, DocValuesFieldUpdates.Iterator
updateIterator) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/ReadersAndUpdates.java:495:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
final long estInfosSize = 40 + 90 * fieldInfos.size();
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'final long estInfosSize = 40L + 90 * fieldInfos.size();'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/ReadersAndUpdates.java:583:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (reader != this.reader) {
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (!reader.equals(this.reader)) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/FieldUpdatesBuffer.java:131:
warning: [ReferenceEquality] Comparison using reference equality instead of
value equality
if (field != fields[0]) { // that's an easy win of not accounting if
there is an outlier
^
(see https://errorprone.info/bugpattern/ReferenceEquality)
Did you mean 'if (!Objects.equals(field, fields[0])) {' or 'if
(!field.equals(fields[0])) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/BytesRefArray.java:247:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
return RamUsageEstimator.NUM_BYTES_ARRAY_HEADER + indices.length *
Integer.BYTES;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'return (long) RamUsageEstimator.NUM_BYTES_ARRAY_HEADER +
indices.length * Integer.BYTES;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/packed/AbstractPagedMutable.java:105:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
+ 3 * Integer.BYTES;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'return (long) RamUsageEstimator.NUM_BYTES_OBJECT_HEADER'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/PrefixCodedTerms.java:193:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object obj) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean 'if (!(obj instanceof PrefixCodedTerms)) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/store/ByteBuffersDataInput.java:184:
warning: [UnnecessaryParentheses] These grouping parentheses are unnecessary;
it is unlikely the code will be misinterpreted without them
return ((readByte(pos ) ) << 24 |
^
(see https://errorprone.info/bugpattern/UnnecessaryParentheses)
Did you mean 'return (readByte(pos ) << 24 |'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/store/MergeInfo.java:64:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object obj) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/codecs/CompoundFormat.java:34:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public CompoundFormat() {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected CompoundFormat() {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushQueue.java:32:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
private final Queue<FlushTicket> queue = new LinkedList<>();
^
(see https://errorprone.info/bugpattern/JdkObsolete)
Did you mean 'private final Queue<FlushTicket> queue = new
ArrayDeque<>();'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java:60:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
private final Queue<DocumentsWriterPerThread> flushQueue = new
LinkedList<>();
^
(see https://errorprone.info/bugpattern/JdkObsolete)
Did you mean 'private final Queue<DocumentsWriterPerThread> flushQueue =
new ArrayDeque<>();'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java:62:
warning: [JdkObsolete] It is very rare for LinkedList to out-perform ArrayList
or ArrayDeque. Avoid it unless you're willing to invest a lot of time into
benchmarking. Caveat: LinkedList supports null elements, but ArrayDeque does
not.
private final Queue<DocumentsWriterPerThread> blockedFlushes = new
LinkedList<>();
^
(see https://errorprone.info/bugpattern/JdkObsolete)
Did you mean 'private final Queue<DocumentsWriterPerThread> blockedFlushes
= new ArrayDeque<>();'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java:88:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
this.hardMaxBytesPerDWPT = config.getRAMPerThreadHardLimitMB() * 1024 *
1024;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'this.hardMaxBytesPerDWPT =
config.getRAMPerThreadHardLimitMB() * 1024L * 1024;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java:336:
warning: [NonAtomicVolatileUpdate] This update of a volatile variable is
non-atomic
numPending--; // write access synced
^
(see https://errorprone.info/bugpattern/NonAtomicVolatileUpdate)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterStallControl.java:77:
warning: [WaitNotInLoop] Because of spurious wakeups, wait(long) must always
be called in a loop
wait(1000);
^
(see https://errorprone.info/bugpattern/WaitNotInLoop)
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/util/IntBlockPool.java:36:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public Allocator(int blockSize) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected Allocator(int blockSize) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/store/FlushInfo.java:56:
warning: [EqualsGetClass] Prefer instanceof to getClass when implementing
Object#equals.
public boolean equals(Object obj) {
^
(see https://errorprone.info/bugpattern/EqualsGetClass)
Did you mean to remove this line?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/index/DocIDMerger.java:42:
warning: [PublicConstructorForAbstractClass] Constructors of on an abstract
class can be declared protected as there is never a need for them to be public
public Sub(MergeState.DocMap docMap) {
^
(see
https://errorprone.info/bugpattern/PublicConstructorForAbstractClass)
Did you mean 'protected Sub(MergeState.DocMap docMap) {'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/codecs/lucene84/Lucene84PostingsWriter.java:284:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
posDeltaBuffer[posBufferUpto] = position - lastPosition;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'posDeltaBuffer[posBufferUpto] = (long) position -
lastPosition;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/codecs/lucene84/Lucene84PostingsWriter.java:302:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
offsetStartDeltaBuffer[posBufferUpto] = startOffset - lastStartOffset;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'offsetStartDeltaBuffer[posBufferUpto] = (long) startOffset -
lastStartOffset;'?
/Users/vthacker/apache-work/lucene-solr/lucene/core/src/java/org/apache/lucene/codecs/lucene84/Lucene84PostingsWriter.java:303:
warning: [IntLongMath] Expression of type int may overflow before being
assigned to a long
offsetLengthBuffer[posBufferUpto] = endOffset - startOffset;
^
(see https://errorprone.info/bugpattern/IntLongMath)
Did you mean 'offsetLengthBuffer[posBufferUpto] = (long) endOffset -
startOffset;'?
100 warnings
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]