Removed unnecessary assertion on boolean values (#20910)
* Removed unnecessary assertion on boolean values * Reversed changes for false assertion * corrected formatting * reverted changes for SettingsUpdater
This commit is contained in:
parent
7e5d8a6e5a
commit
e20d9d6478
|
@ -105,13 +105,13 @@ import static org.apache.lucene.util.ArrayUtil.grow;
|
|||
* <li>vint: frequency (always returned)</li>
|
||||
* <li>
|
||||
* <ul>
|
||||
* <li>vint: position_1 (if positions == true)</li>
|
||||
* <li>vint: startOffset_1 (if offset == true)</li>
|
||||
* <li>vint: endOffset_1 (if offset == true)</li>
|
||||
* <li>BytesRef: payload_1 (if payloads == true)</li>
|
||||
* <li>vint: position_1 (if positions)</li>
|
||||
* <li>vint: startOffset_1 (if offset)</li>
|
||||
* <li>vint: endOffset_1 (if offset)</li>
|
||||
* <li>BytesRef: payload_1 (if payloads)</li>
|
||||
* <li>...</li>
|
||||
* <li>vint: endOffset_freqency (if offset == true)</li>
|
||||
* <li>BytesRef: payload_freqency (if payloads == true)</li>
|
||||
* <li>vint: endOffset_freqency (if offset)</li>
|
||||
* <li>BytesRef: payload_freqency (if payloads)</li>
|
||||
* </ul></li>
|
||||
* </ul>
|
||||
*/
|
||||
|
|
|
@ -397,7 +397,7 @@ public class BigArrays implements Releasable {
|
|||
void adjustBreaker(long delta) {
|
||||
if (this.breakerService != null) {
|
||||
CircuitBreaker breaker = this.breakerService.getBreaker(CircuitBreaker.REQUEST);
|
||||
if (this.checkBreaker == true) {
|
||||
if (this.checkBreaker) {
|
||||
// checking breaker means potentially tripping, but it doesn't
|
||||
// have to if the delta is negative
|
||||
if (delta > 0) {
|
||||
|
|
|
@ -124,7 +124,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
}
|
||||
|
||||
// if we are still fetching, return null to indicate it
|
||||
if (hasAnyNodeFetching(cache) == true) {
|
||||
if (hasAnyNodeFetching(cache)) {
|
||||
return new FetchResult<>(shardId, null, emptySet(), emptySet());
|
||||
} else {
|
||||
// nothing to fetch, yay, build the return value
|
||||
|
@ -137,7 +137,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
|
||||
DiscoveryNode node = nodes.get(nodeId);
|
||||
if (node != null) {
|
||||
if (nodeEntry.isFailed() == true) {
|
||||
if (nodeEntry.isFailed()) {
|
||||
// if its failed, remove it from the list of nodes, so if this run doesn't work
|
||||
// we try again next round to fetch it again
|
||||
it.remove();
|
||||
|
@ -361,7 +361,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
}
|
||||
|
||||
void doneFetching(T value) {
|
||||
assert fetching == true : "setting value but not in fetching mode";
|
||||
assert fetching : "setting value but not in fetching mode";
|
||||
assert failure == null : "setting value when failure already set";
|
||||
this.valueSet = true;
|
||||
this.value = value;
|
||||
|
@ -369,7 +369,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
}
|
||||
|
||||
void doneFetching(Throwable failure) {
|
||||
assert fetching == true : "setting value but not in fetching mode";
|
||||
assert fetching : "setting value but not in fetching mode";
|
||||
assert valueSet == false : "setting failure when already set value";
|
||||
assert failure != null : "setting failure can't be null";
|
||||
this.failure = failure;
|
||||
|
@ -377,7 +377,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
}
|
||||
|
||||
void restartFetching() {
|
||||
assert fetching == true : "restarting fetching, but not in fetching mode";
|
||||
assert fetching : "restarting fetching, but not in fetching mode";
|
||||
assert valueSet == false : "value can't be set when restarting fetching";
|
||||
assert failure == null : "failure can't be set when restarting fetching";
|
||||
this.fetching = false;
|
||||
|
@ -388,7 +388,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
}
|
||||
|
||||
boolean hasData() {
|
||||
return valueSet == true || failure != null;
|
||||
return valueSet || failure != null;
|
||||
}
|
||||
|
||||
Throwable getFailure() {
|
||||
|
@ -399,7 +399,7 @@ public abstract class AsyncShardFetch<T extends BaseNodeResponse> implements Rel
|
|||
@Nullable
|
||||
T getValue() {
|
||||
assert failure == null : "trying to fetch value, but its marked as failed, check isFailed";
|
||||
assert valueSet == true : "value is not set, hasn't been fetched yet";
|
||||
assert valueSet : "value is not set, hasn't been fetched yet";
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class DanglingIndicesState extends AbstractComponent {
|
|||
* for allocation.
|
||||
*/
|
||||
private void allocateDanglingIndices() {
|
||||
if (danglingIndices.isEmpty() == true) {
|
||||
if (danglingIndices.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class GatewayAllocator extends AbstractComponent {
|
|||
boolean cleanCache = false;
|
||||
DiscoveryNode localNode = event.state().nodes().getLocalNode();
|
||||
if (localNode != null) {
|
||||
if (localNode.isMasterNode() == true && event.localNodeMaster() == false) {
|
||||
if (localNode.isMasterNode() && event.localNodeMaster() == false) {
|
||||
cleanCache = true;
|
||||
}
|
||||
} else {
|
||||
|
@ -174,7 +174,7 @@ public class GatewayAllocator extends AbstractComponent {
|
|||
AsyncShardFetch.FetchResult<TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> shardState =
|
||||
fetch.fetchData(allocation.nodes(), allocation.getIgnoreNodes(shard.shardId()));
|
||||
|
||||
if (shardState.hasData() == true) {
|
||||
if (shardState.hasData()) {
|
||||
shardState.processAllocation(allocation);
|
||||
}
|
||||
return shardState;
|
||||
|
@ -199,7 +199,7 @@ public class GatewayAllocator extends AbstractComponent {
|
|||
}
|
||||
AsyncShardFetch.FetchResult<TransportNodesListShardStoreMetaData.NodeStoreFilesMetaData> shardStores =
|
||||
fetch.fetchData(allocation.nodes(), allocation.getIgnoreNodes(shard.shardId()));
|
||||
if (shardStores.hasData() == true) {
|
||||
if (shardStores.hasData()) {
|
||||
shardStores.processAllocation(allocation);
|
||||
}
|
||||
return shardStores;
|
||||
|
|
|
@ -192,7 +192,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateL
|
|||
Set<Index> relevantIndices;
|
||||
if (isDataOnlyNode(state)) {
|
||||
relevantIndices = getRelevantIndicesOnDataOnlyNode(state, previousState, previouslyWrittenIndices);
|
||||
} else if (state.nodes().getLocalNode().isMasterNode() == true) {
|
||||
} else if (state.nodes().getLocalNode().isMasterNode()) {
|
||||
relevantIndices = getRelevantIndicesForMasterEligibleNode(state);
|
||||
} else {
|
||||
relevantIndices = Collections.emptySet();
|
||||
|
|
|
@ -195,7 +195,7 @@ public abstract class PrimaryShardAllocator extends BaseGatewayShardAllocator {
|
|||
"the allocation deciders returned a YES decision to allocate to node [" + nodeId + "]",
|
||||
decidedNode.nodeShardState.allocationId(),
|
||||
buildNodeDecisions(nodesToAllocate, explain));
|
||||
} else if (nodesToAllocate.throttleNodeShards.isEmpty() == true && nodesToAllocate.noNodeShards.isEmpty() == false) {
|
||||
} else if (nodesToAllocate.throttleNodeShards.isEmpty() && !nodesToAllocate.noNodeShards.isEmpty()) {
|
||||
// The deciders returned a NO decision for all nodes with shard copies, so we check if primary shard
|
||||
// can be force-allocated to one of the nodes.
|
||||
final NodesToAllocate nodesToForceAllocate = buildNodesToAllocate(
|
||||
|
|
|
@ -65,7 +65,7 @@ public abstract class ReplicaShardAllocator extends BaseGatewayShardAllocator {
|
|||
List<Runnable> shardCancellationActions = new ArrayList<>();
|
||||
for (RoutingNode routingNode : routingNodes) {
|
||||
for (ShardRouting shard : routingNode) {
|
||||
if (shard.primary() == true) {
|
||||
if (shard.primary()) {
|
||||
continue;
|
||||
}
|
||||
if (shard.initializing() == false) {
|
||||
|
@ -109,7 +109,7 @@ public abstract class ReplicaShardAllocator extends BaseGatewayShardAllocator {
|
|||
}
|
||||
if (currentNode.equals(nodeWithHighestMatch) == false
|
||||
&& Objects.equals(currentSyncId, primaryStore.syncId()) == false
|
||||
&& matchingNodes.isNodeMatchBySyncID(nodeWithHighestMatch) == true) {
|
||||
&& matchingNodes.isNodeMatchBySyncID(nodeWithHighestMatch)) {
|
||||
// we found a better match that has a full sync id match, the existing allocation is not fully synced
|
||||
// so we found a better one, cancel this one
|
||||
logger.debug("cancelling allocation of replica on [{}], sync id match found on node [{}]",
|
||||
|
|
|
@ -68,7 +68,7 @@ public class GeoPointArrayIndexFieldData extends AbstractIndexGeoPointFieldData
|
|||
estimator.afterLoad(null, data.ramBytesUsed());
|
||||
return data;
|
||||
}
|
||||
return (indexSettings.getIndexVersionCreated().before(Version.V_2_2_0) == true) ?
|
||||
return (indexSettings.getIndexVersionCreated().before(Version.V_2_2_0)) ?
|
||||
loadLegacyFieldData(reader, estimator, terms, data) : loadFieldData22(reader, estimator, terms, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ public class LegacyGeoPointFieldMapper extends BaseGeoPointFieldMapper implement
|
|||
validPoint = true;
|
||||
}
|
||||
|
||||
if (coerce.value() == true && validPoint == false) {
|
||||
if (coerce.value() && validPoint == false) {
|
||||
// by setting coerce to false we are assuming all geopoints are already in a valid coordinate system
|
||||
// thus this extra step can be skipped
|
||||
GeoUtils.normalizePoint(point, true, true);
|
||||
|
|
|
@ -299,7 +299,7 @@ public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBounding
|
|||
|
||||
QueryValidationException checkLatLon(boolean indexCreatedBeforeV2_0) {
|
||||
// validation was not available prior to 2.x, so to support bwc percolation queries we only ignore_malformed on 2.x created indexes
|
||||
if (GeoValidationMethod.isIgnoreMalformed(validationMethod) == true || indexCreatedBeforeV2_0) {
|
||||
if (GeoValidationMethod.isIgnoreMalformed(validationMethod) || indexCreatedBeforeV2_0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -408,7 +408,7 @@ public class GeoDistanceQueryBuilder extends AbstractQueryBuilder<GeoDistanceQue
|
|||
optimizeBbox = parser.textOrNull();
|
||||
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, COERCE_FIELD)) {
|
||||
coerce = parser.booleanValue();
|
||||
if (coerce == true) {
|
||||
if (coerce) {
|
||||
ignoreMalformed = true;
|
||||
}
|
||||
} else if (parseContext.getParseFieldMatcher().match(currentFieldName, IGNORE_MALFORMED_FIELD)) {
|
||||
|
|
|
@ -327,7 +327,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
|
|||
} else {
|
||||
fromValue = DistanceUnit.parse((String) from, unit, DistanceUnit.DEFAULT);
|
||||
}
|
||||
if (indexCreatedBeforeV2_2 == true) {
|
||||
if (indexCreatedBeforeV2_2) {
|
||||
fromValue = geoDistance.normalize(fromValue, DistanceUnit.DEFAULT);
|
||||
}
|
||||
} else {
|
||||
|
@ -340,7 +340,7 @@ public class GeoDistanceRangeQueryBuilder extends AbstractQueryBuilder<GeoDistan
|
|||
} else {
|
||||
toValue = DistanceUnit.parse((String) to, unit, DistanceUnit.DEFAULT);
|
||||
}
|
||||
if (indexCreatedBeforeV2_2 == true) {
|
||||
if (indexCreatedBeforeV2_2) {
|
||||
toValue = geoDistance.normalize(toValue, DistanceUnit.DEFAULT);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -65,7 +65,7 @@ public final class ShadowIndexShard extends IndexShard {
|
|||
*/
|
||||
@Override
|
||||
public void updateRoutingEntry(ShardRouting newRouting) throws IOException {
|
||||
if (newRouting.primary() == true) {// becoming a primary
|
||||
if (newRouting.primary()) {// becoming a primary
|
||||
throw new IllegalStateException("can't promote shard to primary");
|
||||
}
|
||||
super.updateRoutingEntry(newRouting);
|
||||
|
|
|
@ -452,7 +452,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
|
|||
geoDistance = GeoDistance.fromString(parser.text());
|
||||
} else if (parseFieldMatcher.match(currentName, COERCE_FIELD)) {
|
||||
coerce = parser.booleanValue();
|
||||
if (coerce == true) {
|
||||
if (coerce) {
|
||||
ignoreMalformed = true;
|
||||
}
|
||||
} else if (parseFieldMatcher.match(currentName, IGNORE_MALFORMED_FIELD)) {
|
||||
|
|
|
@ -84,7 +84,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
|||
assertThat(doc.rootDoc().getField("point.lon"), notNullValue());
|
||||
assertThat(doc.rootDoc().getField("point.lon").fieldType().stored(), is(stored));
|
||||
assertThat(doc.rootDoc().getField("point.geohash"), nullValue());
|
||||
if (indexCreatedBefore22 == true) {
|
||||
if (indexCreatedBefore22) {
|
||||
assertThat(doc.rootDoc().get("point"), equalTo("1.2,1.3"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(doc.rootDoc().get("point")), equalTo(GeoPointField.encodeLatLon(1.2, 1.3)));
|
||||
|
|
|
@ -257,7 +257,7 @@ public class RandomShapeGenerator extends RandomGeoGenerator {
|
|||
if (nearP == null)
|
||||
nearP = xRandomPointIn(r, bounds);
|
||||
|
||||
if (small == true) {
|
||||
if (small) {
|
||||
// between 3 and 6 degrees
|
||||
final double latRange = 3 * r.nextDouble() + 3;
|
||||
final double lonRange = 3 * r.nextDouble() + 3;
|
||||
|
|
Loading…
Reference in New Issue