apache / apache/druid

Walk over IntelliJ's "constant conditions and expressions" inspection results which are unrelated to null

Open
#7,780 1 comment 0 reactions 0 assignees View on GitHub
Bug Contributions Welcome
Dominant language
Java
Stars
14.1k
Forks
3.8k
Avg merge
2d 58m
Merged PRs (30d)
233

Description

IntelliJ's "Constant conditions and expressions" inspection mixes nullability-related problems and other types of problems. In Druid, there are 2500+ nullability related problems which makes the analysis impossible. [You can vote for this issue in YouTrack](https://youtrack.jetbrains.com/issue/IDEABKL-4141) to make it more likely that the problem is solved by IntelliJ developers.

For now, I [worked that around](https://youtrack.jetbrains.com/issue/IDEABKL-4141#focus=streamItem-27-3506899.0-0) and we can analyze actual bugs, 49 of them below.

Please go over the results below and fix the corresponding bugs.
```

file://$PROJECT_DIR$/extensions-contrib/ambari-metrics-emitter/src/main/java/org/apache/druid/emitter/ambari/metrics/AmbariMetricsEmitter.java
195
ambari-metrics-emitter
org.apache.druid.emitter.ambari.metrics

Constant conditions & exceptions
Condition <code>e instanceof InterruptedException</code> is always <code>false</code>

file://$PROJECT_DIR$/core/src/main/java/org/apache/druid/math/expr/Parser.java
111
druid-core
org.apache.druid.math.expr

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/java/util/common/NumbersTest.java
120
druid-core
org.apache.druid.java.util.common

Constant conditions & exceptions
The call to 'parseBoolean' always fails, according to its method contracts

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/java/util/common/NumbersTest.java
112
druid-core
org.apache.druid.java.util.common

Constant conditions & exceptions
Value <code>booleanVal</code> is always 'false'

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/java/util/common/NumbersTest.java
87
druid-core
org.apache.druid.java.util.common

Constant conditions & exceptions
The call to 'parseInt' always fails, according to its method contracts

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/java/util/common/NumbersTest.java
51
druid-core
org.apache.druid.java.util.common

Constant conditions & exceptions
The call to 'parseLong' always fails, according to its method contracts

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/collections/CombiningIteratorTest.java
59
druid-core
org.apache.druid.collections

Constant conditions & exceptions
Value <code>expected</code> is always 'true'

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/collections/CombiningIteratorTest.java
63
druid-core
org.apache.druid.collections

Constant conditions & exceptions
Value <code>expected</code> is always 'true'

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/collections/CombiningIteratorTest.java
83
druid-core
org.apache.druid.collections

Constant conditions & exceptions
Value <code>expected</code> is always 'true'

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/collections/CombiningIteratorTest.java
72
druid-core
org.apache.druid.collections

Constant conditions & exceptions
Value <code>expected</code> is always 'false'

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/collections/CombiningIteratorTest.java
70
druid-core
org.apache.druid.collections

Constant conditions & exceptions
Value <code>expected</code> is always 'true'

file://$PROJECT_DIR$/core/src/test/java/org/apache/druid/collections/CombiningIteratorTest.java
114
druid-core
org.apache.druid.collections

Constant conditions & exceptions
Value <code>expected</code> is always 'false'

file://$PROJECT_DIR$/extensions-core/hdfs-storage/src/test/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusherTest.java
116
druid-hdfs-storage
org.apache.druid.storage.hdfs

Constant conditions & exceptions
The call to 'assertTrue' always fails, according to its method contracts

file://$PROJECT_DIR$/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsTest.java
122
druid-indexing-hadoop
org.apache.druid.indexer

Constant conditions & exceptions
Value <code>overwrite</code> is always 'false'

file://$PROJECT_DIR$/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsCompressionTest.java
116
druid-indexing-hadoop
org.apache.druid.indexer

Constant conditions & exceptions
Value <code>overwrite</code> is always 'true'

file://$PROJECT_DIR$/indexing-hadoop/src/test/java/org/apache/druid/indexer/UtilsCompressionTest.java
103
druid-indexing-hadoop
org.apache.druid.indexer

Constant conditions & exceptions
Value <code>overwrite</code> is always 'true'

file://$PROJECT_DIR$/indexing-hadoop/src/test/java/org/apache/druid/indexer/HadoopIngestionSpecUpdateDatasourcePathSpecSegmentsTest.java
323
druid-indexing-hadoop
org.apache.druid.indexer

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java
813
druid-indexing-service
org.apache.druid.indexing.common.task

Constant conditions & exceptions
Condition <code>unparseable > 0</code> is always <code>false</code>

file://$PROJECT_DIR$/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java
810
druid-indexing-service
org.apache.druid.indexing.common.task

Constant conditions & exceptions
Condition <code>thrownAway > 0</code> is always <code>false</code>

file://$PROJECT_DIR$/indexing-service/src/main/java/org/apache/druid/indexing/common/task/HadoopIndexTask.java
278
druid-indexing-service
org.apache.druid.indexing.common.task

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/indexing-service/src/main/java/org/apache/druid/indexing/worker/WorkerTaskManager.java
184
druid-indexing-service
org.apache.druid.indexing.worker

Constant conditions & exceptions
Condition <code>e instanceof InterruptedException</code> is always <code>false</code>

file://$PROJECT_DIR$/indexing-service/src/main/java/org/apache/druid/indexing/overlord/hrtr/HttpRemoteTaskRunner.java
656
druid-indexing-service
org.apache.druid.indexing.overlord.hrtr

Constant conditions & exceptions
Condition <code>ex instanceof InterruptedException</code> is always <code>false</code>

file://$PROJECT_DIR$/indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/SeekableStreamIndexTaskRunner.java
335
druid-indexing-service
org.apache.druid.indexing.seekablestream

Constant conditions & exceptions
Method <code>runInternal</code> is too complex to analyze by data flow algorithm

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/query/filter/LikeDimFilter.java
69
druid-processing
org.apache.druid.query.filter

Constant conditions & exceptions
Condition <code>escape.isEmpty()</code> is always <code>false</code> when reached

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/query/groupby/GroupByQueryQueryToolChest.java
299
druid-processing
org.apache.druid.query.groupby

Constant conditions & exceptions
Condition <code>q.getDataSource() instanceof QueryDataSource && q.getContextBoolean(GroupByQueryConfig.CT...</code> is always <code>false</code>

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/query/groupby/epinephelinae/ByteBufferMinMaxOffsetHeap.java
299
druid-processing
org.apache.druid.query.groupby.epinephelinae

Constant conditions & exceptions
Condition <code>minChild > -1</code> is always <code>true</code>

file://$PROJECT_DIR$/server/src/main/java/org/apache/druid/client/HttpServerInventoryView.java
462
druid-server
org.apache.druid.client

Constant conditions & exceptions
Condition <code>ex instanceof InterruptedException</code> is always <code>false</code>

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/segment/DimensionHandlerUtils.java
73
druid-processing
org.apache.druid.segment

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/segment/Metadata.java
203
druid-processing
org.apache.druid.segment

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java
374
druid-processing
org.apache.druid.segment.incremental

Constant conditions & exceptions
Condition <code>emptyRange || !baseIter.hasNext()</code> is always <code>true</code> when reached

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java
374
druid-processing
org.apache.druid.segment.incremental

Constant conditions & exceptions
Result of <code>baseIter.hasNext()</code> is always 'false'

file://$PROJECT_DIR$/processing/src/main/java/org/apache/druid/segment/incremental/IncrementalIndexStorageAdapter.java
374
druid-processing
org.apache.druid.segment.incremental

Constant conditions & exceptions
Condition <code>!baseIter.hasNext()</code> is always <code>true</code> when reached

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/scan/ScanQueryRunnerTest.java
923
druid-processing
org.apache.druid.query.scan

Constant conditions & exceptions
Condition <code>i >= dimSpecs.length</code> is always <code>false</code> when reached

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/filter/JavaScriptDimFilterTest.java
107
druid-processing
org.apache.druid.query.filter

Constant conditions & exceptions
The call to 'assertTrue' always fails, according to its method contracts

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/lookup/LookupExtractionFnTest.java
153
druid-processing
org.apache.druid.query.lookup

Constant conditions & exceptions
Value <code>retainMissing</code> is always 'true'

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/select/SelectQueryRunnerTest.java
967
druid-processing
org.apache.druid.query.select

Constant conditions & exceptions
Condition <code>i >= dimSpecs.length</code> is always <code>false</code>

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/select/MultiSegmentSelectQueryTest.java
341
druid-processing
org.apache.druid.query.select

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/groupby/having/DimFilterHavingSpecTest.java
111
druid-processing
org.apache.druid.query.groupby.having

Constant conditions & exceptions
The call to 'assertTrue' always fails, according to its method contracts

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/extraction/JavaScriptExtractionFnTest.java
74
druid-processing
org.apache.druid.query.extraction

Constant conditions & exceptions
The call to 'assertTrue' always fails, according to its method contracts

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/aggregation/JavaScriptAggregatorTest.java
268
druid-processing
org.apache.druid.query.aggregation

Constant conditions & exceptions
The call to 'assertTrue' always fails, according to its method contracts

file://$PROJECT_DIR$/processing/src/test/java/org/apache/druid/query/aggregation/JavaScriptAggregatorTest.java
286
druid-processing
org.apache.druid.query.aggregation

Constant conditions & exceptions
The call to 'assertTrue' always fails, according to its method contracts

file://$PROJECT_DIR$/extensions-core/stats/src/test/java/org/apache/druid/query/aggregation/variance/VarianceAggregatorCollectorTest.java
129
druid-stats
org.apache.druid.query.aggregation.variance

Constant conditions & exceptions
Variable is already assigned to this value

file://$PROJECT_DIR$/sql/src/main/java/org/apache/druid/sql/calcite/planner/Calcites.java
309
druid-sql
org.apache.druid.sql.calcite.planner

Constant conditions & exceptions
Condition <code>typeName == SqlTypeName.DATE</code> is always <code>true</code>

file://$PROJECT_DIR$/sql/src/main/java/org/apache/druid/sql/calcite/filtration/MoveTimeFiltersToIntervals.java
163
druid-sql
org.apache.druid.sql.calcite.filtration

Constant conditions & exceptions
Condition <code>range.hasLowerBound()</code> is always <code>true</code> when reached

file://$PROJECT_DIR$/extendedset/src/main/java/org/apache/druid/extendedset/intset/ConciseSetUtils.java
111
extendedset
org.apache.druid.extendedset.intset

Constant conditions & exceptions
Condition <code>m <= 31</code> is always <code>true</code>

file://$PROJECT_DIR$/extendedset/src/main/java/org/apache/druid/extendedset/intset/ConciseSetUtils.java
112
extendedset
org.apache.druid.extendedset.intset

Constant conditions & exceptions
Condition <code>m == 31</code> is always <code>false</code>

file://$PROJECT_DIR$/extendedset/src/main/java/org/apache/druid/extendedset/intset/ConciseSet.java
161
extendedset
org.apache.druid.extendedset.intset

Constant conditions & exceptions
Condition <code>m <= 31</code> is always <code>true</code>

file://$PROJECT_DIR$/extendedset/src/main/java/org/apache/druid/extendedset/intset/ConciseSet.java
162
extendedset
org.apache.druid.extendedset.intset

Constant conditions & exceptions
Condition <code>m == 31</code> is always <code>false</code>

file://$PROJECT_DIR$/extensions-contrib/graphite-emitter/src/main/java/org/apache/druid/emitter/graphite/GraphiteEmitter.java
212
graphite-emitter
org.apache.druid.emitter.graphite

Constant conditions & exceptions
Condition <code>e instanceof InterruptedException</code> is always <code>false</code>

```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the IntelliJ findings in the listed Java files, beginning with AmbariMetricsEmitter.java, Parser.java, NumbersTest.java, and CombiningIteratorTest.java. Run the affected tests, including NumbersTest, CombiningIteratorTest, HdfsDataSegmentPusherTest, UtilsTest, and UtilsCompressionTest; done means the reported constant-condition problems are fixed and the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.