Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ConfigSchema(Map map, List<String> validationIssues) {
// Potential connection sources and destinations need to have unique ids
CollectionOverlap<String> overlapResults = new CollectionOverlap<>(new HashSet<>(allProcessorIds), new HashSet<>(allRemoteInputPortIds), new HashSet<>(allRemoteOutputPortIds),
new HashSet<>(allInputPortIds), new HashSet<>(allOutputPortIds), new HashSet<>(allFunnelIds));
if (overlapResults.getDuplicates().size() > 0) {
if (!overlapResults.getDuplicates().isEmpty()) {
addValidationIssue(FOUND_THE_FOLLOWING_DUPLICATE_IDS + overlapResults.getDuplicates().stream().sorted().collect(Collectors.joining(", ")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public ProcessGroupSchema(Map map, String wrapperName) {
processGroupSchemas = getOptionalKeyAsList(map, PROCESS_GROUPS_KEY, m -> new ProcessGroupSchema(m, "ProcessGroup(id: {id}, name: {name})"), wrapperName);

if (ConfigSchema.TOP_LEVEL_NAME.equals(wrapperName)) {
if (inputPortSchemas.size() > 0) {
if (!inputPortSchemas.isEmpty()) {
addValidationIssue(INPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported");
}
if (outputPortSchemas.size() > 0) {
if (!outputPortSchemas.isEmpty()) {
addValidationIssue(OUTPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported");
}
} else if (ID_DEFAULT.equals(getId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public RemoteProcessGroupSchema(Map map) {
outputPorts = convertListToType(getOptionalKeyAsType(map, OUTPUT_PORTS_KEY, List.class, wrapperName, new ArrayList<>()), "output port", RemotePortSchema.class, OUTPUT_PORTS_KEY);
addIssuesIfNotNull(outputPorts);

if (inputPorts.size() == 0 && outputPorts.size() == 0) {
if (inputPorts.isEmpty() && outputPorts.isEmpty()) {
addValidationIssue("Expected either '" + INPUT_PORTS_KEY + "', '" + OUTPUT_PORTS_KEY + "' in section '" + wrapperName + "' to have value(s)");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static void putListIfNotNull(Map valueMap, String key, List<? extends Wri
public static void checkForDuplicates(Consumer<String> duplicateMessageConsumer, String errorMessagePrefix, List<String> strings) {
if (strings != null) {
CollectionOverlap<String> collectionOverlap = new CollectionOverlap<>(strings);
if (collectionOverlap.getDuplicates().size() > 0) {
if (!collectionOverlap.getDuplicates().isEmpty()) {
duplicateMessageConsumer.accept(errorMessagePrefix + collectionOverlap.getDuplicates().stream().collect(Collectors.joining(", ")));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected List<ConnectionSchema> getConnectionSchemas(List<ProcessorSchema> proc
connectionSchemas.add(convert);
}

if (problematicDuplicateNames.size() > 0) {
if (!problematicDuplicateNames.isEmpty()) {
validationIssues.add(CANNOT_LOOK_UP_PROCESSOR_ID_FROM_PROCESSOR_NAME_DUE_TO_DUPLICATE_PROCESSOR_NAMES
+ problematicDuplicateNames.stream().collect(Collectors.joining(", ")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public ConfigSchemaV2(Map map, List<String> validationIssues) {
// Potential connection sources and destinations need to have unique ids
CollectionOverlap<String> overlapResults = new CollectionOverlap<>(new HashSet<>(allProcessorIds), new HashSet<>(allRemoteInputPortIds), new HashSet<>(allInputPortIds),
new HashSet<>(allOutputPortIds), new HashSet<>(allFunnelIds));
if (overlapResults.getDuplicates().size() > 0) {
if (!overlapResults.getDuplicates().isEmpty()) {
addValidationIssue(FOUND_THE_FOLLOWING_DUPLICATE_IDS + overlapResults.getDuplicates().stream().sorted().collect(Collectors.joining(", ")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public ProcessGroupSchemaV2(Map map, String wrapperName) {
processGroupSchemas = getOptionalKeyAsList(map, PROCESS_GROUPS_KEY, m -> new ProcessGroupSchemaV2(m, "ProcessGroup(id: {id}, name: {name})"), wrapperName);

if (ConfigSchema.TOP_LEVEL_NAME.equals(wrapperName)) {
if (inputPortSchemas.size() > 0) {
if (!inputPortSchemas.isEmpty()) {
addValidationIssue(INPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported");
}
if (outputPortSchemas.size() > 0) {
if (!outputPortSchemas.isEmpty()) {
addValidationIssue(OUTPUT_PORTS_KEY, wrapperName, "must be empty in root group as external input/output ports are currently unsupported");
}
} else if (ID_DEFAULT.equals(getId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public SiteToSiteClient build() {
* @return the configured URL for the remote NiFi instance
*/
public String getUrl() {
if (urls != null && urls.size() > 0) {
if (urls != null && !urls.isEmpty()) {
return urls.iterator().next();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private Set<PeerStatus> fetchRemotePeerStatuses(SiteToSiteRestApiClient apiClien
// Each node should have the same URL structure and network reachability with the proxy configuration
final Collection<PeerDTO> peers = apiClient.getPeers();
logger.debug("Retrieved {} peers from {}: {}", peers.size(), apiClient.getBaseUrl(), peers);
if (peers.size() == 0) {
if (peers.isEmpty()) {
throw new IOException("Could not get any peer to communicate with. " + apiClient.getBaseUrl() + " returned zero peers.");
}

Expand All @@ -139,7 +139,7 @@ public Transaction createTransaction(final TransferDirection direction) throws I
final String nodeApiUrl = resolveNodeApiUrl(peerStatus.getPeerDescription());
final StringBuilder clusterUrls = new StringBuilder();
config.getUrls().forEach(url -> {
if (clusterUrls.length() > 0) {
if (!clusterUrls.isEmpty()) {
clusterUrls.append(",");
clusterUrls.append(url);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,17 +1266,17 @@ public static String getFirstUrl(final String clusterUrlStr) {
*/
public static Set<String> parseClusterUrls(final String clusterUrlStr) {
final Set<String> urls = new LinkedHashSet<>();
if (clusterUrlStr != null && clusterUrlStr.length() > 0) {
if (clusterUrlStr != null && !clusterUrlStr.isEmpty()) {
Arrays.stream(clusterUrlStr.split(","))
.map(s -> s.trim())
.filter(s -> s.length() > 0)
.filter(s -> !s.isEmpty())
.forEach(s -> {
validateUriString(s);
urls.add(resolveBaseUrl(s).intern());
});
}

if (urls.size() == 0) {
if (urls.isEmpty()) {
throw new IllegalArgumentException("Cluster URL was not specified.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) {
final List<FlowFile> flowFiles = session.get(context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger());
if (flowFiles == null || flowFiles.size() == 0) {
if (flowFiles == null || flowFiles.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public List<ConfigVerificationResult> verify(final ProcessContext context, final
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) {
final List<FlowFile> flowFiles = session.get(context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger());
if (flowFiles == null || flowFiles.size() == 0) {
if (flowFiles == null || flowFiles.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
@Override
public void onTrigger(final ProcessContext context, final ProcessSession session) {
List<FlowFile> flowFiles = session.get(context.getProperty(BATCH_SIZE).evaluateAttributeExpressions().asInteger());
if (flowFiles == null || flowFiles.size() == 0) {
if (flowFiles == null || flowFiles.isEmpty()) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
final String streamName = entry.getKey();
final List<Record> records = entry.getValue();

if (records.size() > 0) {
if (!records.isEmpty()) {
// Send the batch
final PutRecordBatchRequest putRecordBatchRequest = PutRecordBatchRequest.builder()
.deliveryStreamName(streamName)
Expand Down Expand Up @@ -174,11 +174,11 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
}
}

if (failedFlowFiles.size() > 0) {
if (!failedFlowFiles.isEmpty()) {
session.transfer(failedFlowFiles, REL_FAILURE);
getLogger().error("Failed to publish to kinesis firehose {}", failedFlowFiles);
}
if (successfulFlowFiles.size() > 0) {
if (!successfulFlowFiles.isEmpty()) {
session.transfer(successfulFlowFiles, REL_SUCCESS);
getLogger().info("Successfully published to kinesis firehose {}", successfulFlowFiles);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ protected synchronized void persistLocalState(final String s3ObjectKey, final Mu
props.remove(s3ObjectKey);
}

if (props.size() > 0) {
if (!props.isEmpty()) {
try (final FileOutputStream fos = new FileOutputStream(persistenceFile)) {
props.store(fos, null);
} catch (IOException ioe) {
Expand Down Expand Up @@ -628,7 +628,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
} else {
attributes.put(S3_STORAGECLASS_ATTR_KEY, StorageClass.Standard.toString());
}
if (userMetadata.size() > 0) {
if (!userMetadata.isEmpty()) {
StringBuilder userMetaBldr = new StringBuilder();
for (String userKey : userMetadata.keySet()) {
userMetaBldr.append(userKey).append("=").append(userMetadata.get(userKey));
Expand All @@ -652,7 +652,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
try {
currentState = getLocalStateIfInS3(s3, bucket, cacheKey);
if (currentState != null) {
if (currentState.getPartETags().size() > 0) {
if (!currentState.getPartETags().isEmpty()) {
final PartETag lastETag = currentState.getPartETags().get(
currentState.getPartETags().size() - 1);
getLogger().info("Resuming upload for flowfile='{}' bucket='{}' key='{}' " +
Expand Down Expand Up @@ -820,7 +820,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
if (currentState.getStorageClass() != null) {
attributes.put(S3_STORAGECLASS_ATTR_KEY, currentState.getStorageClass().toString());
}
if (userMetadata.size() > 0) {
if (!userMetadata.isEmpty()) {
StringBuilder userMetaBldr = new StringBuilder();
for (String userKey : userMetadata.keySet()) {
userMetaBldr.append(userKey).append("=").append(userMetadata.get(userKey));
Expand Down Expand Up @@ -1059,7 +1059,7 @@ public String toString() {
StringBuilder buf = new StringBuilder();
buf.append(uploadId).append(SEPARATOR)
.append(filePosition.toString()).append(SEPARATOR);
if (partETags.size() > 0) {
if (!partETags.isEmpty()) {
boolean first = true;
for (PartETag tag : partETags) {
if (!first) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
batch = new ArrayList<>();
}
}
if (!error && batch.size() > 0) {
if (!error && !batch.isEmpty()) {
bulkInsert(batch);
}
} catch (SchemaNotFoundException | MalformedRecordException | IOException | CosmosException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public BinaryReader build() throws IOException {
}

public byte[] toByteArray() throws IOException {
if (data.size() == 0) {
if (data.isEmpty()) {
return new byte[0];
} else if (data.size() == 1) {
return data.get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void onTrigger(ProcessContext context, ProcessSession session) throws Pro

// if the size is 0 then there was nothing to process so return
// we don't need to yield here because we have a long poll in side of getBatches
if (batches.size() == 0) {
if (batches.isEmpty()) {
return;
}

Expand All @@ -95,7 +95,7 @@ public void onTrigger(ProcessContext context, ProcessSession session) throws Pro
FlowFile flowFile = entry.getValue().getFlowFile();
final List<E> events = entry.getValue().getEvents();

if (flowFile.getSize() == 0L || events.size() == 0) {
if (flowFile.getSize() == 0L || events.isEmpty()) {
session.remove(flowFile);
getLogger().debug("No data written to FlowFile from batch {}; removing FlowFile", entry.getKey());
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ public void listByTrackingTimestamps(final ProcessContext context, final Process

int entitiesListed = 0;

if (orderedEntries.size() > 0) {
if (!orderedEntries.isEmpty()) {
latestListedEntryTimestampThisCycleMillis = orderedEntries.lastKey();

// Determine target system time precision.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void trackEntities(ProcessContext context, ProcessSession session,

final Collection<T> listedEntities = listEntities.apply(minTimestampToList);

if (listedEntities.size() == 0) {
if (listedEntities.isEmpty()) {
logger.debug("No entity is listed. Yielding.");
context.yield();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private Relationship leftShift(Relationship r, SessionFile f) {
/** to support: REL_SUCCESS << sessionFileCollection */
@SuppressWarnings("unchecked")
private Relationship leftShift(Relationship r, Collection sfl) {
if (sfl != null && sfl.size() > 0) {
if (sfl != null && !sfl.isEmpty()) {
ProcessSessionWrap session = ((SessionFile) sfl.iterator().next()).session();
List<FlowFile> ffl = session.unwrap(sfl);
//assume all files has the same session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void onTrigger(ProcessContext context, ProcessSession session) throws Pro
} finally {
queueLock.unlock();
}
if (listedFiles.size() > 0) {
if (!listedFiles.isEmpty()) {
logEmptyListing.set(3L);
}
if (logEmptyListing.getAndDecrement() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ private StringBuilder toJsonString(StringBuilder sb) {
appendProperty(sb, "status", this.error);
}

if (this.getChildren() != null && this.getChildren().size() > 0) {
if (this.getChildren() != null && !this.getChildren().isEmpty()) {
sb.append(",\"content\":[");
for (HDFSObjectInfoDetails c : this.getChildren()) {
c.toJsonString(sb).append(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public void onTrigger(ProcessContext context, ProcessSession session) throws Pro
} finally {
queueLock.unlock();
}
if (listedFiles.size() > 0) {
if (!listedFiles.isEmpty()) {
logEmptyListing.set(3L);
}
if (logEmptyListing.getAndDecrement() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
sent++;
}

if (batch.size() > 0) {
if (!batch.isEmpty()) {
try {
writeBatch(buildBatch(batch, jsonTypeSetting, usePrettyPrint), input, context, session, attributes, REL_SUCCESS);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
writeModels = new ArrayList<>();
}
}
if (writeModels.size() > 0) {
if (!writeModels.isEmpty()) {
collection.bulkWrite(writeModels, bulkWriteOptions);
}
} catch (ProcessException | SchemaNotFoundException | IOException | MalformedRecordException | MongoException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Optional<Object> lookup(Map<String, Object> coordinates, Map<String, Stri
));
Document query = new Document(clean);

if (coordinates.size() == 0) {
if (coordinates.isEmpty()) {
throw new LookupFailureException("No keys were configured. Mongo query would return random documents.");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public <K, V> boolean replace(final AtomicCacheEntry<K, V, byte[]> entry, final
final List<Object> results = redisConnection.exec();

// if we have a result then the replace succeeded
if (results != null && results.size() > 0) {
if (results != null && !results.isEmpty()) {
replaced = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public <K, V> V getAndPutIfAbsent(final K key, final V value, final Serializer<K
// if the results list was empty, then the transaction failed (i.e. key was modified after we started watching), so keep looping to retry
// if the results list was null, then the transaction failed
// if the results list has results, then the transaction succeeded and it should have the result of the setNX operation
if (results != null && results.size() > 0) {
if (results != null && !results.isEmpty()) {
final Object firstResult = results.get(0);
if (firstResult instanceof Boolean) {
final Boolean absent = (Boolean) firstResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public boolean replace(final StateMap oldValue, final Map<String, String> newVal

// if we have a result then the replace succeeded
// results can be null if the transaction has been aborted
if (results != null && results.size() > 0) {
if (results != null && !results.isEmpty()) {
replaced = true;
}

Expand Down
Loading