Enable Spotbugs NP_NONNULL_RETURN_VIOLATION (#8234)

This commit is contained in:
Fokko Driesprong 2019-08-20 16:23:46 +02:00 committed by Roman Leventov
parent 781873ba53
commit 818bf4990c
15 changed files with 32 additions and 9 deletions

View File

@ -60,7 +60,6 @@
<Bug pattern="NP_LOAD_OF_KNOWN_NULL_VALUE"/>
<Bug pattern="NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION"/>
<Bug pattern="NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
<Bug pattern="NP_NONNULL_RETURN_VIOLATION"/>
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
<Bug pattern="NP_NULL_ON_SOME_PATH_MIGHT_BE_INFEASIBLE"/>

View File

@ -249,6 +249,7 @@ public class TimestampAggregatorFactory extends AggregatorFactory
return result;
}
@Nullable
static Long convertLong(TimestampSpec timestampSpec, Object input)
{
if (input instanceof Number) {

View File

@ -269,6 +269,7 @@ public class GroupByQueryEngine
this.max = max - increment; // Make sure there is enough room for one more increment
}
@Nullable
public Integer getNext()
{
if (nextVal > max) {

View File

@ -19,9 +19,12 @@
package org.apache.druid.segment;
import javax.annotation.Nullable;
public abstract class AbstractSegment implements Segment
{
@Override
@Nullable
public <T> T as(Class<T> clazz)
{
if (clazz.equals(QueryableIndex.class)) {

View File

@ -182,6 +182,7 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector
}
@Override
@Nullable
public BitmapIndex getBitmapIndex(String dimension)
{
if (isVirtualColumn(dimension)) {
@ -204,6 +205,7 @@ public class ColumnSelectorBitmapIndexSelector implements BitmapIndexSelector
}
@Override
@Nullable
public String getValue(int index)
{
return null;

View File

@ -25,6 +25,8 @@ import org.apache.druid.segment.column.ColumnCapabilities;
import org.apache.druid.segment.selector.settable.SettableColumnValueSelector;
import org.apache.druid.segment.writeout.SegmentWriteOutMedium;
import javax.annotation.Nullable;
import java.util.Comparator;
/**
@ -70,6 +72,7 @@ public interface DimensionHandler
* Get {@link MultiValueHandling} for the column associated with this handler.
* Only string columns can have {@link MultiValueHandling} currently.
*/
@Nullable
default MultiValueHandling getMultivalueHandling()
{
return null;

View File

@ -88,6 +88,7 @@ public interface IndexMerger
}
}
@Nullable
static List<String> getLongestSharedDimOrder(List<IndexableAdapter> indexes)
{
int maxSize = 0;

View File

@ -27,6 +27,8 @@ import org.apache.druid.segment.data.GenericIndexed;
import org.apache.druid.segment.data.VSizeColumnarMultiInts;
import org.joda.time.Interval;
import javax.annotation.Nullable;
import java.util.Map;
/**
@ -85,15 +87,10 @@ public class MMappedIndex
return dataInterval;
}
@Nullable
public MetricHolder getMetricHolder(String metric)
{
final MetricHolder retVal = metrics.get(metric);
if (retVal == null) {
return null;
}
return retVal;
return metrics.get(metric);
}
public GenericIndexed<String> getDimValueLookup(String dimension)

View File

@ -26,6 +26,8 @@ import org.apache.druid.timeline.SegmentId;
import org.apache.druid.timeline.partition.ShardSpec;
import org.joda.time.Interval;
import javax.annotation.Nullable;
import java.io.Closeable;
import java.util.concurrent.Phaser;
import java.util.concurrent.atomic.AtomicBoolean;
@ -111,6 +113,7 @@ public class ReferenceCountingSegment extends AbstractSegment implements Oversha
this.atomicUpdateGroupSize = atomicUpdateGroupSize;
}
@Nullable
public Segment getBaseSegment()
{
return !isClosed() ? baseSegment : null;
@ -127,24 +130,28 @@ public class ReferenceCountingSegment extends AbstractSegment implements Oversha
}
@Override
@Nullable
public SegmentId getId()
{
return !isClosed() ? baseSegment.getId() : null;
}
@Override
@Nullable
public Interval getDataInterval()
{
return !isClosed() ? baseSegment.getDataInterval() : null;
}
@Override
@Nullable
public QueryableIndex asQueryableIndex()
{
return !isClosed() ? baseSegment.asQueryableIndex() : null;
}
@Override
@Nullable
public StorageAdapter asStorageAdapter()
{
return !isClosed() ? baseSegment.asStorageAdapter() : null;

View File

@ -57,5 +57,6 @@ public interface Segment extends Closeable
* @param <T> desired interface
* @return instance of clazz, or null if the interface is not supported by this segment
*/
@Nullable
<T> T as(Class<T> clazz);
}

View File

@ -101,6 +101,7 @@ public class StringDimensionIndexer implements DimensionIndexer<Integer, int[],
}
}
@Nullable
public String getValue(int id)
{
lock.readLock().lock();

View File

@ -173,6 +173,7 @@ public class VirtualColumns implements Cacheable
}
}
@Nullable
public BitmapIndex getBitmapIndex(String columnName, ColumnSelector columnSelector)
{
final VirtualColumn virtualColumn = getVirtualColumn(columnName);
@ -273,7 +274,7 @@ public class VirtualColumns implements Cacheable
return new CacheKeyBuilder((byte) 0).appendCacheablesIgnoringOrder(virtualColumns).build();
}
private void detectCycles(VirtualColumn virtualColumn, Set<String> columnNames)
private void detectCycles(VirtualColumn virtualColumn, @Nullable Set<String> columnNames)
{
// Copy columnNames to avoid modifying it
final Set<String> nextSet = columnNames == null

View File

@ -726,6 +726,7 @@ public abstract class IncrementalIndex<AggregatorType> extends AbstractIndex imp
return new IncrementalIndexRowResult(incrementalIndexRow, parseExceptionMessages);
}
@Nullable
public static ParseException getCombinedParseException(
InputRow row,
@Nullable List<String> dimParseExceptionMessages,

View File

@ -33,6 +33,8 @@ import org.apache.druid.data.input.impl.SpatialDimensionSchema;
import org.apache.druid.java.util.common.ISE;
import org.joda.time.DateTime;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -208,6 +210,7 @@ public class SpatialDimensionRowTransformer implements Function<InputRow, InputR
return true;
}
@Nullable
private static Float tryParseFloat(String val)
{
try {
@ -225,6 +228,7 @@ public class SpatialDimensionRowTransformer implements Function<InputRow, InputR
*
* @return decoded coordinate, or null if it could not be decoded
*/
@Nullable
public static float[] decode(final String encodedCoordinate)
{
if (encodedCoordinate == null) {

View File

@ -70,6 +70,7 @@ public abstract class ComplexMetricSerde
*
* @return A function that can compute the size of the complex object or null if you cannot/do not want to compute it
*/
@Nullable
public Function<Object, Long> inputSizeFn()
{
return null;