From 6b945e4952352a9e88f6cdb5d2b2b202353f9444 Mon Sep 17 00:00:00 2001 From: dan-s1 Date: Thu, 26 Dec 2024 20:14:53 +0000 Subject: [PATCH] NIFI-14109 Refactored remaining processors and control services to be uniform when creating properties and relationships. --- .../processors/AbstractAMQPProcessor.java | 27 +++----- .../nifi/amqp/processors/ConsumeAMQP.java | 49 +++++++-------- .../nifi/amqp/processors/PublishAMQP.java | 2 +- .../StandardAsanaClientProviderService.java | 4 +- .../StandardS3EncryptionService.java | 13 ++-- .../AmazonGlueSchemaRegistry.java | 5 +- ...dardAzureCredentialsControllerService.java | 3 +- .../document/AzureCosmosDBClientService.java | 4 +- .../explorer/StandardKustoIngestService.java | 4 +- .../explorer/StandardKustoQueryService.java | 4 +- .../eventhub/AzureEventHubRecordSink.java | 4 +- .../ConfluentSchemaRegistry.java | 22 ++++--- .../StandardDropboxCredentialService.java | 18 ++---- .../ElasticSearchClientServiceImpl.java | 30 +++++++-- .../ElasticSearchStringLookupService.java | 11 +++- .../AbstractListenEventBatchingProcessor.java | 42 +++++++------ .../listen/AbstractListenEventProcessor.java | 24 +++++--- .../util/file/transfer/PutFileTransfer.java | 15 ++--- .../hadoop/AbstractHadoopProcessor.java | 14 ++--- .../hadoop/AbstractFetchHDFSRecord.java | 13 ++-- .../hadoop/AbstractPutHDFSRecord.java | 14 ++--- .../GCPCredentialsControllerService.java | 21 +++---- .../gcp/storage/GCSFileResourceService.java | 3 +- .../processors/geohash/GeohashRecord.java | 34 ++++------- .../nifi/graph/Neo4JCypherClientService.java | 29 ++++----- .../nifi/graph/TinkerpopClientService.java | 8 +-- .../hadoop/CreateHadoopSequenceFile.java | 31 +++++----- .../nifi/processors/hadoop/DeleteHDFS.java | 29 +++++---- .../nifi/processors/hadoop/FetchHDFS.java | 28 +++++---- .../nifi/processors/hadoop/GetHDFS.java | 45 +++++++------- .../processors/hadoop/GetHDFSFileInfo.java | 45 ++++++++------ .../nifi/processors/hadoop/ListHDFS.java | 26 +++++--- .../nifi/processors/hadoop/MoveHDFS.java | 41 +++++++------ .../nifi/processors/hadoop/PutHDFS.java | 61 ++++++++++--------- .../hadoop/inotify/GetHDFSEvents.java | 27 +++++--- .../StandardHashiCorpVaultClientService.java | 20 +++--- .../cacheclient/HazelcastMapCacheClient.java | 18 ++---- .../JndiJmsConnectionFactoryProperties.java | 4 +- .../service/Kafka3ConnectionService.java | 4 +- .../image/ExtractImageMetadata.java | 29 +++------ .../media/ExtractMediaMetadata.java | 37 ++++------- .../mongodb/MongoDBControllerService.java | 22 +++---- .../apache/nifi/parquet/ParquetReader.java | 9 +-- .../StandardPGPPrivateKeyService.java | 5 +- .../standard/StandardPGPPublicKeyService.java | 5 +- ...RedisDistributedMapCacheClientService.java | 15 ++--- .../apache/nifi/redis/util/RedisUtils.java | 54 ++++++++-------- .../services/AvroSchemaRegistry.java | 19 ++---- .../services/StandardJsonSchemaRegistry.java | 7 ++- .../sink/SiteToSiteReportingRecordSink.java | 30 +++++---- .../nifi/services/slack/SlackRecordSink.java | 20 +++--- .../nifi/processors/smb/PutSmbFile.java | 51 +++++++--------- .../smb/SmbjClientProviderService.java | 27 ++++---- .../DatabaseTableSchemaRegistry.java | 14 ++--- .../record/sink/db/DatabaseRecordSink.java | 36 +++++------ .../nifi/dbcp/HikariCPConnectionPool.java | 34 +++++------ .../cache/client/MapCacheClientService.java | 15 ++--- .../cache/client/SetCacheClientService.java | 15 ++--- .../service/StandardFileResourceService.java | 3 +- .../nifi/dbcp/HadoopDBCPConnectionPool.java | 45 ++++++-------- .../nifi/http/StandardHttpContextMap.java | 11 ++-- .../service/StandardPrivateKeyService.java | 5 +- .../DistributedMapCacheLookupService.java | 11 ++-- .../apache/nifi/lookup/RestLookupService.java | 40 ++++++------ .../CommonsConfigurationLookupService.java | 16 ++--- .../db/AbstractDatabaseLookupService.java | 7 +-- .../db/DatabaseRecordLookupService.java | 26 ++++---- .../db/SimpleDatabaseLookupService.java | 22 +++---- .../nifi/lookup/maxmind/IPLookupService.java | 19 +++--- .../StandardOauth2AccessTokenProvider.java | 5 +- .../StandardProxyConfigurationService.java | 18 +++--- .../org/apache/nifi/lookup/ReaderLookup.java | 5 +- .../nifi/lookup/RecordSetWriterLookup.java | 5 +- .../schema/inference/VolatileSchemaCache.java | 7 ++- .../text/FreeFormTextRecordSetWriter.java | 11 ++-- .../nifi/record/sink/EmailRecordSink.java | 36 +++++------ .../nifi/record/sink/HttpRecordSink.java | 18 +++--- .../nifi/record/sink/LoggingRecordSink.java | 22 +++---- .../record/sink/event/UDPEventRecordSink.java | 16 ++--- .../ssl/PEMEncodedSSLContextProvider.java | 4 +- .../nifi/ssl/StandardSSLContextService.java | 4 +- .../StandardWebClientServiceProvider.java | 5 +- .../controller/service/mock/ServiceA.java | 9 ++- .../controller/service/mock/ServiceC.java | 11 ++-- .../controller/service/mock/ServiceD.java | 9 ++- ...lassloaderIsolationKeyProviderService.java | 5 +- ...ControllerServiceConfigurationCorrect.java | 8 ++- .../tests/system/LifecycleFailureService.java | 6 +- .../cs/tests/system/StandardCountService.java | 6 +- .../cs/tests/system/StandardSleepService.java | 15 +++-- 90 files changed, 800 insertions(+), 870 deletions(-) diff --git a/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/AbstractAMQPProcessor.java b/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/AbstractAMQPProcessor.java index 9e08118f17f1..47c27a81457c 100644 --- a/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/AbstractAMQPProcessor.java +++ b/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/AbstractAMQPProcessor.java @@ -139,23 +139,16 @@ abstract class AbstractAMQPProcessor extends AbstractProce .addValidator(StandardValidators.BOOLEAN_VALIDATOR) .build(); - private static final List propertyDescriptors; - - static { - propertyDescriptors = List.of( - BROKERS, - HOST, PORT, - V_HOST, - USER, - PASSWORD, - AMQP_VERSION, - SSL_CONTEXT_SERVICE, - USE_CERT_AUTHENTICATION); - } - - protected static List getCommonPropertyDescriptors() { - return propertyDescriptors; - } + protected static final List PARENT_PROPERTIES = List.of( + BROKERS, + HOST, PORT, + V_HOST, + USER, + PASSWORD, + AMQP_VERSION, + SSL_CONTEXT_SERVICE, + USE_CERT_AUTHENTICATION + ); private BlockingQueue> resourceQueue; diff --git a/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/ConsumeAMQP.java b/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/ConsumeAMQP.java index b9837e1738bc..144b20863285 100644 --- a/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/ConsumeAMQP.java +++ b/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/ConsumeAMQP.java @@ -40,13 +40,12 @@ import org.apache.nifi.processor.util.StandardValidators; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import java.util.stream.Stream; @Tags({"amqp", "rabbit", "get", "message", "receive", "consume"}) @InputRequirement(Requirement.INPUT_FORBIDDEN) @@ -163,28 +162,24 @@ public class ConsumeAMQP extends AbstractAMQPProcessor { .description("All FlowFiles that are received from the AMQP queue are routed to this relationship") .build(); - private static final List propertyDescriptors; - private static final Set relationships; - - private static final ObjectMapper objectMapper; - - static { - List properties = new ArrayList<>(); - properties.add(QUEUE); - properties.add(AUTO_ACKNOWLEDGE); - properties.add(BATCH_SIZE); - properties.add(PREFETCH_COUNT); - properties.add(HEADER_FORMAT); - properties.add(HEADER_KEY_PREFIX); - properties.add(HEADER_SEPARATOR); - properties.add(REMOVE_CURLY_BRACES); - properties.addAll(getCommonPropertyDescriptors()); - propertyDescriptors = Collections.unmodifiableList(properties); - - relationships = Set.of(REL_SUCCESS); - - objectMapper = new ObjectMapper(); - } + private static final List PROPERTIES = Stream.concat( + Stream.of( + QUEUE, + AUTO_ACKNOWLEDGE, + BATCH_SIZE, + PREFETCH_COUNT, + HEADER_FORMAT, + HEADER_KEY_PREFIX, + HEADER_SEPARATOR, + REMOVE_CURLY_BRACES + ), PARENT_PROPERTIES.stream() + ).toList(); + + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS + ); + + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); /** * Will construct a {@link FlowFile} containing the body of the consumed AMQP message (if {@link GetResponse} returned by {@link AMQPConsumer} is @@ -303,7 +298,7 @@ private static String convertMapToString(Map headers, String val } private static String convertMapToJSONString(Map headers) throws JsonProcessingException { - return objectMapper.writeValueAsString(headers); + return OBJECT_MAPPER.writeValueAsString(headers); } @Override @@ -320,12 +315,12 @@ protected synchronized AMQPConsumer createAMQPWorker(final ProcessContext contex @Override protected List getSupportedPropertyDescriptors() { - return propertyDescriptors; + return PROPERTIES; } @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } public enum OutputHeaderFormat implements DescribedValue { diff --git a/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java b/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java index dedb92ed23b3..57430fdbdd2d 100644 --- a/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java +++ b/nifi-extension-bundles/nifi-amqp-bundle/nifi-amqp-processors/src/main/java/org/apache/nifi/amqp/processors/PublishAMQP.java @@ -140,7 +140,7 @@ public class PublishAMQP extends AbstractAMQPProcessor { HEADERS_PATTERN, HEADER_SEPARATOR ), - getCommonPropertyDescriptors().stream() + PARENT_PROPERTIES.stream() ).toList(); private final static Set RELATIONSHIPS = Set.of( diff --git a/nifi-extension-bundles/nifi-asana-bundle/nifi-asana-services/src/main/java/org/apache/nifi/controller/asana/StandardAsanaClientProviderService.java b/nifi-extension-bundles/nifi-asana-bundle/nifi-asana-services/src/main/java/org/apache/nifi/controller/asana/StandardAsanaClientProviderService.java index f8bcfb9ff1ca..5d38dcf644eb 100644 --- a/nifi-extension-bundles/nifi-asana-bundle/nifi-asana-services/src/main/java/org/apache/nifi/controller/asana/StandardAsanaClientProviderService.java +++ b/nifi-extension-bundles/nifi-asana-bundle/nifi-asana-services/src/main/java/org/apache/nifi/controller/asana/StandardAsanaClientProviderService.java @@ -71,7 +71,7 @@ public class StandardAsanaClientProviderService extends AbstractControllerServic .addValidator(StandardValidators.NON_BLANK_VALIDATOR) .build(); - protected static final List DESCRIPTORS = List.of( + private static final List PROPERTIES = List.of( PROP_ASANA_API_BASE_URL, PROP_ASANA_PERSONAL_ACCESS_TOKEN, PROP_ASANA_WORKSPACE_NAME @@ -83,7 +83,7 @@ public class StandardAsanaClientProviderService extends AbstractControllerServic @Override public List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/encryption/StandardS3EncryptionService.java b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/encryption/StandardS3EncryptionService.java index 66ad6bbd70c4..bc6734d739f8 100644 --- a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/encryption/StandardS3EncryptionService.java +++ b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/s3/encryption/StandardS3EncryptionService.java @@ -45,7 +45,6 @@ import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Consumer; @@ -110,6 +109,12 @@ STRATEGY_NAME_CSE_C, new ClientSideCEncryptionStrategy() .defaultValue(RegionUtilV1.createAllowableValue(Regions.DEFAULT_REGION).getValue()) .build(); + private static final List PROPERTIES = List.of( + ENCRYPTION_STRATEGY, + ENCRYPTION_VALUE, + KMS_REGION + ); + private String keyValue = ""; private String kmsRegion = ""; private S3EncryptionStrategy encryptionStrategy = new NoOpEncryptionStrategy(); @@ -189,11 +194,7 @@ protected Collection customValidate(final ValidationContext va @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(ENCRYPTION_STRATEGY); - properties.add(ENCRYPTION_VALUE); - properties.add(KMS_REGION); - return Collections.unmodifiableList(properties); + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java index e6b3572312e9..296c47eaa748 100644 --- a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java +++ b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java @@ -53,7 +53,6 @@ import java.net.URI; import java.time.Duration; import java.util.ArrayList; -import java.util.Arrays; import java.util.Comparator; import java.util.EnumSet; import java.util.List; @@ -137,7 +136,7 @@ public class AmazonGlueSchemaRegistry extends AbstractControllerService implemen private static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS); - private static final List PROPERTIES = new ArrayList<>(Arrays.asList( + private static final List PROPERTIES = List.of( SCHEMA_REGISTRY_NAME, REGION, COMMUNICATIONS_TIMEOUT, @@ -146,7 +145,7 @@ public class AmazonGlueSchemaRegistry extends AbstractControllerService implemen AWS_CREDENTIALS_PROVIDER_SERVICE, PROXY_CONFIGURATION_SERVICE, SSL_CONTEXT_SERVICE - )); + ); @Override diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/StandardAzureCredentialsControllerService.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/StandardAzureCredentialsControllerService.java index 3295fd5c996e..cc8ba362130f 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/StandardAzureCredentialsControllerService.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/StandardAzureCredentialsControllerService.java @@ -69,7 +69,8 @@ public class StandardAzureCredentialsControllerService extends AbstractControlle .build(); private static final List PROPERTIES = List.of( - CREDENTIAL_CONFIGURATION_STRATEGY, MANAGED_IDENTITY_CLIENT_ID + CREDENTIAL_CONFIGURATION_STRATEGY, + MANAGED_IDENTITY_CLIENT_ID ); private TokenCredential credentials; diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AzureCosmosDBClientService.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AzureCosmosDBClientService.java index 1963c5640958..31462a349131 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AzureCosmosDBClientService.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AzureCosmosDBClientService.java @@ -83,7 +83,7 @@ protected void createCosmosClient(final String uri, final String accessKey, fina .buildClient(); } - static List descriptors = List.of( + private static final List PROPERTIES = List.of( AzureCosmosDBUtils.URI, AzureCosmosDBUtils.DB_ACCESS_KEY, AzureCosmosDBUtils.CONSISTENCY @@ -91,7 +91,7 @@ protected void createCosmosClient(final String uri, final String accessKey, fina @Override protected List getSupportedPropertyDescriptors() { - return descriptors; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoIngestService.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoIngestService.java index 6ee5bb21dd69..c8fb941b139a 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoIngestService.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoIngestService.java @@ -105,7 +105,7 @@ public class StandardKustoIngestService extends AbstractControllerService implem .addValidator(StandardValidators.URL_VALIDATOR) .build(); - private static final List PROPERTY_DESCRIPTORS = List.of( + private static final List PROPERTIES = List.of( AUTHENTICATION_STRATEGY, APPLICATION_CLIENT_ID, APPLICATION_KEY, @@ -127,7 +127,7 @@ public class StandardKustoIngestService extends AbstractControllerService implem @Override public List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoQueryService.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoQueryService.java index c904243fb832..e5522c24c287 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoQueryService.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/data/explorer/StandardKustoQueryService.java @@ -83,7 +83,7 @@ public class StandardKustoQueryService extends AbstractControllerService impleme .dependsOn(AUTHENTICATION_STRATEGY, KustoAuthenticationStrategy.APPLICATION_CREDENTIALS) .build(); - private static final List PROPERTY_DESCRIPTORS = List.of( + private static final List PROPERTIES = List.of( CLUSTER_URI, AUTHENTICATION_STRATEGY, APPLICATION_CLIENT_ID, @@ -95,7 +95,7 @@ public class StandardKustoQueryService extends AbstractControllerService impleme @Override public List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } public static final Pair NIFI_SOURCE = Pair.of("processor", "nifi-source"); diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/eventhub/AzureEventHubRecordSink.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/eventhub/AzureEventHubRecordSink.java index 739b207d9f17..a249280ce801 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/eventhub/AzureEventHubRecordSink.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/eventhub/AzureEventHubRecordSink.java @@ -125,7 +125,7 @@ public class AzureEventHubRecordSink extends AbstractControllerService implement .required(false) .build(); - private static final List PROPERTY_DESCRIPTORS = List.of( + private static final List PROPERTIES = List.of( SERVICE_BUS_ENDPOINT, EVENT_HUB_NAMESPACE, EVENT_HUB_NAME, @@ -143,7 +143,7 @@ public class AzureEventHubRecordSink extends AbstractControllerService implement @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } protected EventHubProducerClient createEventHubClient(final String namespace, diff --git a/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistry.java b/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistry.java index 7277395fb831..f45b223197e7 100644 --- a/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistry.java +++ b/nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/ConfluentSchemaRegistry.java @@ -148,21 +148,23 @@ public class ConfluentSchemaRegistry extends AbstractControllerService implement .sensitive(true) .build(); + private static final List PROPERTIES = List.of( + SCHEMA_REGISTRY_URLS, + SSL_CONTEXT, + TIMEOUT, + CACHE_SIZE, + CACHE_EXPIRATION, + AUTHENTICATION_TYPE, + USERNAME, + PASSWORD + ); + private volatile SchemaRegistryClient client; @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(SCHEMA_REGISTRY_URLS); - properties.add(SSL_CONTEXT); - properties.add(TIMEOUT); - properties.add(CACHE_SIZE); - properties.add(CACHE_EXPIRATION); - properties.add(AUTHENTICATION_TYPE); - properties.add(USERNAME); - properties.add(PASSWORD); - return properties; + return PROPERTIES; } private static final Validator REQUEST_HEADER_VALIDATOR = new Validator() { diff --git a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/main/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialService.java b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/main/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialService.java index f1510b502c3f..905baeada97d 100644 --- a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/main/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialService.java +++ b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-services/src/main/java/org/apache/nifi/services/dropbox/StandardDropboxCredentialService.java @@ -16,8 +16,6 @@ */ package org.apache.nifi.services.dropbox; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.Tags; @@ -77,16 +75,12 @@ public class StandardDropboxCredentialService extends AbstractControllerService .required(true) .build(); - private static final List PROPERTIES; - - static { - final List props = new ArrayList<>(); - props.add(APP_KEY); - props.add(APP_SECRET); - props.add(ACCESS_TOKEN); - props.add(REFRESH_TOKEN); - PROPERTIES = Collections.unmodifiableList(props); - } + private static final List PROPERTIES = List.of( + APP_KEY, + APP_SECRET, + ACCESS_TOKEN, + REFRESH_TOKEN + ); private DropboxCredentialDetails credential; diff --git a/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java b/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java index 8169a38f0636..4ee00c21a96b 100644 --- a/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java +++ b/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientServiceImpl.java @@ -102,10 +102,30 @@ public class ElasticSearchClientServiceImpl extends AbstractControllerService im private ObjectMapper mapper; - private static final List properties = List.of(HTTP_HOSTS, PATH_PREFIX, AUTHORIZATION_SCHEME, USERNAME, PASSWORD, API_KEY_ID, API_KEY, - PROP_SSL_CONTEXT_SERVICE, PROXY_CONFIGURATION_SERVICE, CONNECT_TIMEOUT, SOCKET_TIMEOUT, CHARSET, - SUPPRESS_NULLS, COMPRESSION, SEND_META_HEADER, STRICT_DEPRECATION, NODE_SELECTOR, SNIFF_CLUSTER_NODES, - SNIFFER_INTERVAL, SNIFFER_REQUEST_TIMEOUT, SNIFF_ON_FAILURE, SNIFFER_FAILURE_DELAY); + private static final List PROPERTIES = List.of( + HTTP_HOSTS, + PATH_PREFIX, + AUTHORIZATION_SCHEME, + USERNAME, + PASSWORD, + API_KEY_ID, + API_KEY, + PROP_SSL_CONTEXT_SERVICE, + PROXY_CONFIGURATION_SERVICE, + CONNECT_TIMEOUT, + SOCKET_TIMEOUT, + CHARSET, + SUPPRESS_NULLS, + COMPRESSION, + SEND_META_HEADER, + STRICT_DEPRECATION, + NODE_SELECTOR, + SNIFF_CLUSTER_NODES, + SNIFFER_INTERVAL, + SNIFFER_REQUEST_TIMEOUT, + SNIFF_ON_FAILURE, + SNIFFER_FAILURE_DELAY + ); private RestClient client; @@ -117,7 +137,7 @@ public class ElasticSearchClientServiceImpl extends AbstractControllerService im @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchStringLookupService.java b/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchStringLookupService.java index 18810729af6b..2746386779e0 100644 --- a/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchStringLookupService.java +++ b/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchStringLookupService.java @@ -30,7 +30,6 @@ import org.apache.nifi.processor.util.StandardValidators; import java.io.IOException; -import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; @@ -64,7 +63,13 @@ public class ElasticSearchStringLookupService extends AbstractControllerService .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); - private static final List DESCRIPTORS = Arrays.asList(CLIENT_SERVICE, INDEX, TYPE); + + private static final List PROPERTIES = List.of( + CLIENT_SERVICE, + INDEX, + TYPE + ); + private static final ObjectMapper mapper = new ObjectMapper(); public static final String ID = "es_document_id"; private ElasticSearchClientService esClient; @@ -73,7 +78,7 @@ public class ElasticSearchStringLookupService extends AbstractControllerService @Override protected List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventBatchingProcessor.java b/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventBatchingProcessor.java index 8192b11b668a..273bf6a8617e 100644 --- a/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventBatchingProcessor.java +++ b/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventBatchingProcessor.java @@ -22,18 +22,16 @@ import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessSession; import org.apache.nifi.processor.ProcessorInitializationContext; -import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.listen.event.Event; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.apache.nifi.processor.util.listen.ListenerProperties.NETWORK_INTF_NAME; @@ -45,27 +43,31 @@ */ public abstract class AbstractListenEventBatchingProcessor extends AbstractListenEventProcessor { + private static final List PROPERTIES = List.of( + NETWORK_INTF_NAME, + PORT, + RECV_BUFFER_SIZE, + MAX_MESSAGE_QUEUE_SIZE, + MAX_SOCKET_BUFFER_SIZE, + CHARSET, + ListenerProperties.MAX_BATCH_SIZE, + ListenerProperties.MESSAGE_DELIMITER + ); + // it is only the array reference that is volatile - not the contents. protected volatile byte[] messageDemarcatorBytes; @Override protected void init(final ProcessorInitializationContext context) { - final List descriptors = new ArrayList<>(); - descriptors.add(NETWORK_INTF_NAME); - descriptors.add(PORT); - descriptors.add(RECV_BUFFER_SIZE); - descriptors.add(MAX_MESSAGE_QUEUE_SIZE); - descriptors.add(MAX_SOCKET_BUFFER_SIZE); - descriptors.add(CHARSET); - descriptors.add(ListenerProperties.MAX_BATCH_SIZE); - descriptors.add(ListenerProperties.MESSAGE_DELIMITER); - descriptors.addAll(getAdditionalProperties()); - this.descriptors = Collections.unmodifiableList(descriptors); - - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.addAll(getAdditionalRelationships()); - this.relationships = Collections.unmodifiableSet(relationships); + this.descriptors = Stream.concat( + PROPERTIES.stream(), + getAdditionalProperties().stream() + ).toList(); + + relationships = Stream.concat( + Stream.of(REL_SUCCESS), + getAdditionalRelationships().stream() + ).collect(Collectors.toUnmodifiableSet()); } @Override diff --git a/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventProcessor.java b/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventProcessor.java index 3f8933816300..1d57bf824e02 100644 --- a/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventProcessor.java +++ b/nifi-extension-bundles/nifi-extension-utils/nifi-event-listen/src/main/java/org/apache/nifi/processor/util/listen/AbstractListenEventProcessor.java @@ -36,7 +36,6 @@ import java.net.InetAddress; import java.nio.charset.Charset; import java.time.Instant; -import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -45,6 +44,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Stream; import static org.apache.nifi.processor.util.listen.ListenerProperties.NETWORK_INTF_NAME; @@ -109,6 +109,15 @@ public abstract class AbstractListenEventProcessor extends Abst public static final int POLL_TIMEOUT_MS = 20; + private static final List PROPERTIES = List.of( + NETWORK_INTF_NAME, + PORT, + RECV_BUFFER_SIZE, + MAX_MESSAGE_QUEUE_SIZE, + MAX_SOCKET_BUFFER_SIZE, + CHARSET + ); + protected Set relationships; protected List descriptors; @@ -124,15 +133,10 @@ public abstract class AbstractListenEventProcessor extends Abst @Override protected void init(final ProcessorInitializationContext context) { - final List descriptors = new ArrayList<>(); - descriptors.add(NETWORK_INTF_NAME); - descriptors.add(PORT); - descriptors.add(RECV_BUFFER_SIZE); - descriptors.add(MAX_MESSAGE_QUEUE_SIZE); - descriptors.add(MAX_SOCKET_BUFFER_SIZE); - descriptors.add(CHARSET); - descriptors.addAll(getAdditionalProperties()); - this.descriptors = Collections.unmodifiableList(descriptors); + this.descriptors = Stream.concat( + PROPERTIES.stream(), + getAdditionalProperties().stream() + ).toList(); final Set relationships = new HashSet<>(); relationships.add(REL_SUCCESS); diff --git a/nifi-extension-bundles/nifi-extension-utils/nifi-file-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/PutFileTransfer.java b/nifi-extension-bundles/nifi-extension-utils/nifi-file-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/PutFileTransfer.java index a5ce9d8c2032..8b6a1fd7d359 100644 --- a/nifi-extension-bundles/nifi-extension-utils/nifi-file-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/PutFileTransfer.java +++ b/nifi-extension-bundles/nifi-extension-utils/nifi-file-transfer/src/main/java/org/apache/nifi/processor/util/file/transfer/PutFileTransfer.java @@ -32,8 +32,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.Collections; -import java.util.HashSet; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; @@ -58,20 +56,19 @@ public abstract class PutFileTransfer extends AbstractPr .description("FlowFiles that were rejected by the destination system") .build(); - private final Set relationships; + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_FAILURE, + REL_REJECT + ); public PutFileTransfer() { super(); - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.add(REL_FAILURE); - relationships.add(REL_REJECT); - this.relationships = Collections.unmodifiableSet(relationships); } @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } protected abstract T getFileTransfer(final ProcessContext context); diff --git a/nifi-extension-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java b/nifi-extension-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java index 842f2d7b20fd..c81a234c99f7 100644 --- a/nifi-extension-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java +++ b/nifi-extension-bundles/nifi-extension-utils/nifi-hadoop-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractHadoopProcessor.java @@ -141,7 +141,11 @@ public abstract class AbstractHadoopProcessor extends AbstractProcessor implemen private static final Object RESOURCES_LOCK = new Object(); private static final HdfsResources EMPTY_HDFS_RESOURCES = new HdfsResources(null, null, null, null); - protected List properties; + protected static final List PARENT_PROPERTIES = List.of( + HADOOP_CONFIGURATION_RESOURCES, + KERBEROS_USER_SERVICE, + ADDITIONAL_CLASSPATH_RESOURCES + ); // variables shared by all threads of this processor // Hadoop Configuration, Filesystem, and UserGroupInformation (optional) @@ -153,12 +157,6 @@ public abstract class AbstractHadoopProcessor extends AbstractProcessor implemen @Override protected void init(ProcessorInitializationContext context) { hdfsResources.set(EMPTY_HDFS_RESOURCES); - - properties = List.of( - HADOOP_CONFIGURATION_RESOURCES, - KERBEROS_USER_SERVICE, - ADDITIONAL_CLASSPATH_RESOURCES - ); } @Override @@ -172,7 +170,7 @@ public void migrateProperties(final PropertyConfiguration config) { @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PARENT_PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractFetchHDFSRecord.java b/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractFetchHDFSRecord.java index 4524caafbbf3..067e7f8f6cb2 100644 --- a/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractFetchHDFSRecord.java +++ b/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractFetchHDFSRecord.java @@ -50,7 +50,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -109,13 +108,13 @@ public abstract class AbstractFetchHDFSRecord extends AbstractHadoopProcessor { protected final void init(final ProcessorInitializationContext context) { super.init(context); - final Set rels = new HashSet<>(); - rels.add(REL_SUCCESS); - rels.add(REL_RETRY); - rels.add(REL_FAILURE); - this.fetchHdfsRecordRelationships = Collections.unmodifiableSet(rels); + this.fetchHdfsRecordRelationships = Set.of( + REL_SUCCESS, + REL_RETRY, + REL_FAILURE + ); - final List props = new ArrayList<>(properties); + final List props = new ArrayList<>(PARENT_PROPERTIES); props.add(FILENAME); props.add(RECORD_WRITER); props.addAll(getAdditionalProperties()); diff --git a/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractPutHDFSRecord.java b/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractPutHDFSRecord.java index e2ec0e86d581..c02f08beb85b 100644 --- a/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractPutHDFSRecord.java +++ b/nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-hadoop-record-utils/src/main/java/org/apache/nifi/processors/hadoop/AbstractPutHDFSRecord.java @@ -55,7 +55,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -147,14 +146,13 @@ public abstract class AbstractPutHDFSRecord extends AbstractHadoopProcessor { @Override protected final void init(final ProcessorInitializationContext context) { super.init(context); + this.putHdfsRecordRelationships = Set.of( + REL_SUCCESS, + REL_RETRY, + REL_FAILURE + ); - final Set rels = new HashSet<>(); - rels.add(REL_SUCCESS); - rels.add(REL_RETRY); - rels.add(REL_FAILURE); - this.putHdfsRecordRelationships = Collections.unmodifiableSet(rels); - - final List props = new ArrayList<>(properties); + final List props = new ArrayList<>(PARENT_PROPERTIES); props.add(RECORD_READER); props.add(new PropertyDescriptor.Builder() diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java index a4a5a20bbbda..19af7d7f28b2 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java @@ -41,7 +41,6 @@ import org.apache.nifi.reporting.InitializationException; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -73,24 +72,20 @@ ) public class GCPCredentialsControllerService extends AbstractControllerService implements GCPCredentialsService, VerifiableControllerService { - private static final List properties; - - static { - final List props = new ArrayList<>(); - props.add(USE_APPLICATION_DEFAULT_CREDENTIALS); - props.add(USE_COMPUTE_ENGINE_CREDENTIALS); - props.add(SERVICE_ACCOUNT_JSON_FILE); - props.add(SERVICE_ACCOUNT_JSON); - props.add(ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS)); - properties = Collections.unmodifiableList(props); - } + private static final List PROPERTIES = List.of( + USE_APPLICATION_DEFAULT_CREDENTIALS, + USE_COMPUTE_ENGINE_CREDENTIALS, + SERVICE_ACCOUNT_JSON_FILE, + SERVICE_ACCOUNT_JSON, + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS) + ); private volatile GoogleCredentials googleCredentials; protected final CredentialsFactory credentialsProviderFactory = new CredentialsFactory(); @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } public GoogleCredentials getGoogleCredentials() throws ProcessException { diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/GCSFileResourceService.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/GCSFileResourceService.java index 0f99897fcdb6..cdfaa1ecdd4b 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/GCSFileResourceService.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/GCSFileResourceService.java @@ -44,7 +44,6 @@ import java.io.IOException; import java.nio.channels.Channels; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -89,7 +88,7 @@ public class GCSFileResourceService extends AbstractControllerService implements .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); - private static final List PROPERTIES = Arrays.asList( + private static final List PROPERTIES = List.of( BUCKET, KEY, GoogleUtils.GCP_CREDENTIALS_PROVIDER_SERVICE diff --git a/nifi-extension-bundles/nifi-geohash-bundle/nifi-geohash-processors/src/main/java/org/apache/nifi/processors/geohash/GeohashRecord.java b/nifi-extension-bundles/nifi-geohash-bundle/nifi-geohash-processors/src/main/java/org/apache/nifi/processors/geohash/GeohashRecord.java index 2cb676bf49c5..fe44e08444ca 100644 --- a/nifi-extension-bundles/nifi-geohash-bundle/nifi-geohash-processors/src/main/java/org/apache/nifi/processors/geohash/GeohashRecord.java +++ b/nifi-extension-bundles/nifi-geohash-bundle/nifi-geohash-processors/src/main/java/org/apache/nifi/processors/geohash/GeohashRecord.java @@ -31,7 +31,6 @@ import org.apache.nifi.processor.AbstractProcessor; import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.record.path.FieldValue; @@ -56,10 +55,8 @@ import java.io.InputStream; import java.io.OutputStream; -import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.ArrayList; import java.util.Map; import java.util.HashMap; import java.util.Optional; @@ -226,29 +223,24 @@ public enum RoutingStrategy { REL_FAILURE ); + private static final List PROPERTIES = List.of( + MODE, + RECORD_READER, + RECORD_WRITER, + ROUTING_STRATEGY, + LATITUDE_RECORD_PATH, + LONGITUDE_RECORD_PATH, + GEOHASH_RECORD_PATH, + GEOHASH_FORMAT, + GEOHASH_LEVEL + ); + private RoutingStrategyExecutor routingStrategyExecutor; private static boolean isSplit; private static Integer enrichedCount, unenrichedCount; private final RecordPathCache cache = new RecordPathCache(100); - private List descriptors; - - @Override - protected void init(final ProcessorInitializationContext context) { - descriptors = new ArrayList<>(); - descriptors.add(MODE); - descriptors.add(RECORD_READER); - descriptors.add(RECORD_WRITER); - descriptors.add(ROUTING_STRATEGY); - descriptors.add(LATITUDE_RECORD_PATH); - descriptors.add(LONGITUDE_RECORD_PATH); - descriptors.add(GEOHASH_RECORD_PATH); - descriptors.add(GEOHASH_FORMAT); - descriptors.add(GEOHASH_LEVEL); - descriptors = Collections.unmodifiableList(descriptors); - } - @Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { if (descriptor.equals(ROUTING_STRATEGY)) { @@ -263,7 +255,7 @@ public Set getRelationships() { @Override public final List getSupportedPropertyDescriptors() { - return descriptors; + return PROPERTIES; } @OnScheduled diff --git a/nifi-extension-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypherClientService.java b/nifi-extension-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypherClientService.java index be7b018bc7c0..9a34b4765bde 100644 --- a/nifi-extension-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypherClientService.java +++ b/nifi-extension-bundles/nifi-graph-bundle/nifi-neo4j-cypher-service/src/main/java/org/apache/nifi/graph/Neo4JCypherClientService.java @@ -43,7 +43,6 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -156,21 +155,17 @@ public class Neo4JCypherClientService extends AbstractControllerService implemen protected String password; protected String connectionUrl; - private static final List DESCRIPTORS; - static { - List _temp = new ArrayList<>(); - _temp.add(CONNECTION_URL); - _temp.add(USERNAME); - _temp.add(PASSWORD); - _temp.add(CONNECTION_TIMEOUT); - _temp.add(MAX_CONNECTION_POOL_SIZE); - _temp.add(MAX_CONNECTION_ACQUISITION_TIMEOUT); - _temp.add(IDLE_TIME_BEFORE_CONNECTION_TEST); - _temp.add(MAX_CONNECTION_LIFETIME); - _temp.add(SSL_TRUST_STORE_FILE); - - DESCRIPTORS = Collections.unmodifiableList(_temp); - } + private static final List PROPERTIES = List.of( + CONNECTION_URL, + USERNAME, + PASSWORD, + CONNECTION_TIMEOUT, + MAX_CONNECTION_POOL_SIZE, + MAX_CONNECTION_ACQUISITION_TIMEOUT, + IDLE_TIME_BEFORE_CONNECTION_TEST, + MAX_CONNECTION_LIFETIME, + SSL_TRUST_STORE_FILE + ); @Override protected Collection customValidate(ValidationContext validationContext) { @@ -191,7 +186,7 @@ protected Collection customValidate(ValidationContext validati @Override public List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } protected Driver getDriver(ConfigurationContext context) { diff --git a/nifi-extension-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/TinkerpopClientService.java b/nifi-extension-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/TinkerpopClientService.java index da557d1097f9..3c39c9e27c36 100644 --- a/nifi-extension-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/TinkerpopClientService.java +++ b/nifi-extension-bundles/nifi-graph-bundle/nifi-other-graph-services/src/main/java/org/apache/nifi/graph/TinkerpopClientService.java @@ -57,9 +57,7 @@ import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -219,7 +217,7 @@ public class TinkerpopClientService extends AbstractControllerService implements .identifiesControllerService(SSLContextProvider.class) .build(); - public static final List DESCRIPTORS = Collections.unmodifiableList(Arrays.asList( + public static final List PROPERTIES = List.of( SUBMISSION_TYPE, CONNECTION_SETTINGS, REMOTE_OBJECTS_FILE, @@ -232,7 +230,7 @@ public class TinkerpopClientService extends AbstractControllerService implements USER_NAME, PASSWORD, SSL_CONTEXT_SERVICE - )); + ); private GroovyShell groovyShell; private Map compiledCode; @@ -298,7 +296,7 @@ public String getTransitUrl() { @Override public List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/CreateHadoopSequenceFile.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/CreateHadoopSequenceFile.java index 2ea7b46bdb51..b1ccf99ba86c 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/CreateHadoopSequenceFile.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/CreateHadoopSequenceFile.java @@ -36,12 +36,10 @@ import org.apache.nifi.processors.hadoop.util.SequenceFileWriter; import org.apache.nifi.util.StopWatch; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; /** *

@@ -83,14 +81,7 @@ public class CreateHadoopSequenceFile extends AbstractHadoopProcessor { .name("failure") .description("Incoming files that failed to generate a Sequence File are sent to this relationship") .build(); - private static final Set relationships; - static { - Set rels = new HashSet<>(); - rels.add(RELATIONSHIP_SUCCESS); - rels.add(RELATIONSHIP_FAILURE); - relationships = Collections.unmodifiableSet(rels); - } // Optional Properties. static final PropertyDescriptor COMPRESSION_TYPE = new PropertyDescriptor.Builder() .displayName("Compression type") @@ -102,17 +93,27 @@ public class CreateHadoopSequenceFile extends AbstractHadoopProcessor { // Default Values. public static final String DEFAULT_COMPRESSION_TYPE = "NONE"; + private static final Set RELATIONSHIPS = Set.of( + RELATIONSHIP_SUCCESS, + RELATIONSHIP_FAILURE + ); + + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + COMPRESSION_TYPE, + COMPRESSION_CODEC + ) + ).toList(); + @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } @Override public List getSupportedPropertyDescriptors() { - List someProps = new ArrayList<>(properties); - someProps.add(COMPRESSION_TYPE); - someProps.add(COMPRESSION_CODEC); - return someProps; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/DeleteHDFS.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/DeleteHDFS.java index 5544f2de966f..4f514768d56d 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/DeleteHDFS.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/DeleteHDFS.java @@ -43,14 +43,12 @@ import java.io.IOException; import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Stream; @InputRequirement(InputRequirement.Requirement.INPUT_ALLOWED) @Tags({"hadoop", "HCFS", "HDFS", "delete", "remove", "filesystem"}) @@ -109,26 +107,27 @@ public class DeleteHDFS extends AbstractHadoopProcessor { protected final Pattern GLOB_PATTERN = Pattern.compile("\\[|\\]|\\*|\\?|\\^|\\{|\\}|\\\\c"); protected final Matcher GLOB_MATCHER = GLOB_PATTERN.matcher(""); - private static final Set relationships; + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_FAILURE + ); - static { - final Set relationshipSet = new HashSet<>(); - relationshipSet.add(REL_SUCCESS); - relationshipSet.add(REL_FAILURE); - relationships = Collections.unmodifiableSet(relationshipSet); - } + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + FILE_OR_DIRECTORY, + RECURSIVE + ) + ).toList(); @Override protected List getSupportedPropertyDescriptors() { - List props = new ArrayList<>(properties); - props.add(FILE_OR_DIRECTORY); - props.add(RECURSIVE); - return props; + return PROPERTIES; } @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/FetchHDFS.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/FetchHDFS.java index 74b28b2b88eb..a7e2cdace5b1 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/FetchHDFS.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/FetchHDFS.java @@ -53,11 +53,10 @@ import java.io.IOException; import java.io.InputStream; import java.security.PrivilegedAction; -import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; @SupportsBatching @InputRequirement(Requirement.INPUT_REQUIRED) @@ -101,21 +100,28 @@ public class FetchHDFS extends AbstractHadoopProcessor { + "This generally indicates that the Fetch should be tried again.") .build(); + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_FAILURE, + REL_COMMS_FAILURE + ); + + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + FILENAME, + COMPRESSION_CODEC + ) + ).toList(); + @Override protected List getSupportedPropertyDescriptors() { - final List props = new ArrayList<>(properties); - props.add(FILENAME); - props.add(COMPRESSION_CODEC); - return props; + return PROPERTIES; } @Override public Set getRelationships() { - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.add(REL_FAILURE); - relationships.add(REL_COMMS_FAILURE); - return relationships; + return RELATIONSHIPS; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFS.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFS.java index a87398d83ed0..d9a9e9933d56 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFS.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFS.java @@ -57,7 +57,6 @@ import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -68,6 +67,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; +import java.util.stream.Stream; @TriggerWhenEmpty @InputRequirement(Requirement.INPUT_FORBIDDEN) @@ -178,11 +178,27 @@ public class GetHDFS extends AbstractHadoopProcessor { .addValidator(StandardValidators.DATA_SIZE_VALIDATOR) .build(); - private static final Set relationships; - - static { - relationships = Collections.singleton(REL_SUCCESS); - } + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS + ); + + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + DIRECTORY, + RECURSE_SUBDIRS, + KEEP_SOURCE_FILE, + FILE_FILTER_REGEX, + FILTER_MATCH_NAME_ONLY, + IGNORE_DOTTED_FILES, + MIN_AGE, + MAX_AGE, + POLLING_INTERVAL, + BATCH_SIZE, + BUFFER_SIZE, + COMPRESSION_CODEC + ) + ).toList(); protected ProcessorConfiguration processorConfig; private final AtomicLong logEmptyListing = new AtomicLong(2L); @@ -196,25 +212,12 @@ public class GetHDFS extends AbstractHadoopProcessor { @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } @Override protected List getSupportedPropertyDescriptors() { - List props = new ArrayList<>(properties); - props.add(DIRECTORY); - props.add(RECURSE_SUBDIRS); - props.add(KEEP_SOURCE_FILE); - props.add(FILE_FILTER_REGEX); - props.add(FILTER_MATCH_NAME_ONLY); - props.add(IGNORE_DOTTED_FILES); - props.add(MIN_AGE); - props.add(MAX_AGE); - props.add(POLLING_INTERVAL); - props.add(BATCH_SIZE); - props.add(BUFFER_SIZE); - props.add(COMPRESSION_CODEC); - return props; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFSFileInfo.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFSFileInfo.java index cff5a916d17a..c683946987b3 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFSFileInfo.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/GetHDFSFileInfo.java @@ -21,12 +21,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Stream; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; @@ -230,6 +230,29 @@ public class GetHDFSFileInfo extends AbstractHadoopProcessor { .description("All failed attempts to access HDFS will be routed to this relationship") .build(); + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + FULL_PATH, + RECURSE_SUBDIRS, + DIR_FILTER, + FILE_FILTER, + FILE_EXCLUDE_FILTER, + IGNORE_DOTTED_DIRS, + IGNORE_DOTTED_FILES, + GROUPING, + BATCH_SIZE, + DESTINATION + ) + ).toList(); + + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_NOT_FOUND, + REL_ORIGINAL, + REL_FAILURE + ); + @Override protected void init(final ProcessorInitializationContext context) { super.init(context); @@ -237,28 +260,12 @@ protected void init(final ProcessorInitializationContext context) { @Override protected List getSupportedPropertyDescriptors() { - final List props = new ArrayList<>(properties); - props.add(FULL_PATH); - props.add(RECURSE_SUBDIRS); - props.add(DIR_FILTER); - props.add(FILE_FILTER); - props.add(FILE_EXCLUDE_FILTER); - props.add(IGNORE_DOTTED_DIRS); - props.add(IGNORE_DOTTED_FILES); - props.add(GROUPING); - props.add(BATCH_SIZE); - props.add(DESTINATION); - return props; + return PROPERTIES; } @Override public Set getRelationships() { - final Set relationships = new HashSet<>(); - relationships.add(REL_SUCCESS); - relationships.add(REL_NOT_FOUND); - relationships.add(REL_ORIGINAL); - relationships.add(REL_FAILURE); - return relationships; + return RELATIONSHIPS; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/ListHDFS.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/ListHDFS.java index f703287b88e5..166cc2ef5477 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/ListHDFS.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/ListHDFS.java @@ -52,9 +52,7 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -162,9 +160,23 @@ public class ListHDFS extends AbstractHadoopProcessor { public static final String LATEST_TIMESTAMP_KEY = "latest.timestamp"; public static final String LATEST_FILES_KEY = "latest.file.%d"; - private static final List LIST_HDFS_PROPERTIES = Arrays.asList( - DIRECTORY, RECURSE_SUBDIRS, RECORD_WRITER, FILE_FILTER, FILE_FILTER_MODE, MINIMUM_FILE_AGE, MAXIMUM_FILE_AGE); - private static final Set RELATIONSHIPS = Collections.singleton(REL_SUCCESS); + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + DIRECTORY, + RECURSE_SUBDIRS, + RECORD_WRITER, + FILE_FILTER, + FILE_FILTER_MODE, + MINIMUM_FILE_AGE, + MAXIMUM_FILE_AGE + ) + ).toList(); + + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS + ); + private Pattern fileFilterRegexPattern; private volatile boolean resetState = false; @@ -177,9 +189,7 @@ protected void preProcessConfiguration(Configuration config, ProcessContext cont @Override protected List getSupportedPropertyDescriptors() { - final List props = new ArrayList<>(properties); - props.addAll(LIST_HDFS_PROPERTIES); - return props; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/MoveHDFS.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/MoveHDFS.java index 578d0cc5866f..2fb0c4488015 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/MoveHDFS.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/MoveHDFS.java @@ -56,7 +56,6 @@ import java.security.PrivilegedAction; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -69,6 +68,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.regex.Pattern; +import java.util.stream.Stream; /** * This processor renames files on HDFS. @@ -98,8 +98,6 @@ public class MoveHDFS extends AbstractHadoopProcessor { public static final String IGNORE_RESOLUTION = "ignore"; public static final String FAIL_RESOLUTION = "fail"; - private static final Set relationships; - public static final AllowableValue REPLACE_RESOLUTION_AV = new AllowableValue(REPLACE_RESOLUTION, REPLACE_RESOLUTION, "Replaces the existing file if any."); public static final AllowableValue IGNORE_RESOLUTION_AV = new AllowableValue(IGNORE_RESOLUTION, IGNORE_RESOLUTION, @@ -185,12 +183,24 @@ public class MoveHDFS extends AbstractHadoopProcessor { .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); - static { - final Set rels = new HashSet<>(); - rels.add(REL_SUCCESS); - rels.add(REL_FAILURE); - relationships = Collections.unmodifiableSet(rels); - } + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_FAILURE + ); + + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + CONFLICT_RESOLUTION, + INPUT_DIRECTORY_OR_FILE, + OUTPUT_DIRECTORY, + OPERATION, + FILE_FILTER_REGEX, + IGNORE_DOTTED_FILES, + REMOTE_OWNER, + REMOTE_GROUP + ) + ).toList(); // non-static global protected ProcessorConfiguration processorConfig; @@ -205,21 +215,12 @@ public class MoveHDFS extends AbstractHadoopProcessor { // methods @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } @Override protected List getSupportedPropertyDescriptors() { - List props = new ArrayList<>(properties); - props.add(CONFLICT_RESOLUTION); - props.add(INPUT_DIRECTORY_OR_FILE); - props.add(OUTPUT_DIRECTORY); - props.add(OPERATION); - props.add(FILE_FILTER_REGEX); - props.add(IGNORE_DOTTED_FILES); - props.add(REMOTE_OWNER); - props.add(REMOTE_GROUP); - return props; + return PROPERTIES; } @OnScheduled diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java index 8acce88fd235..4262166c6d26 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/PutHDFS.java @@ -75,13 +75,13 @@ import java.time.Duration; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.EnumSet; -import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; import java.io.InputStream; +import java.util.stream.Stream; + import org.apache.nifi.processors.transfer.ResourceTransferSource; import static org.apache.nifi.processors.transfer.ResourceTransferProperties.FILE_RESOURCE_SERVICE; import static org.apache.nifi.processors.transfer.ResourceTransferProperties.RESOURCE_TRANSFER_SOURCE; @@ -234,41 +234,42 @@ public class PutHDFS extends AbstractHadoopProcessor { .addValidator(StandardValidators.BOOLEAN_VALIDATOR) .build(); - private static final Set relationships; - - static { - final Set rels = new HashSet<>(); - rels.add(REL_SUCCESS); - rels.add(REL_FAILURE); - relationships = Collections.unmodifiableSet(rels); - } + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_FAILURE + ); + + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + new PropertyDescriptor.Builder() + .fromPropertyDescriptor(DIRECTORY) + .description("The parent HDFS directory to which files should be written. The directory will be created if it doesn't exist.") + .build(), + CONFLICT_RESOLUTION, + APPEND_MODE, + WRITING_STRATEGY, + BLOCK_SIZE, + BUFFER_SIZE, + REPLICATION_FACTOR, + UMASK, + REMOTE_OWNER, + REMOTE_GROUP, + COMPRESSION_CODEC, + IGNORE_LOCALITY, + RESOURCE_TRANSFER_SOURCE, + FILE_RESOURCE_SERVICE + ) + ).toList(); @Override public Set getRelationships() { - return relationships; + return RELATIONSHIPS; } @Override protected List getSupportedPropertyDescriptors() { - List props = new ArrayList<>(properties); - props.add(new PropertyDescriptor.Builder() - .fromPropertyDescriptor(DIRECTORY) - .description("The parent HDFS directory to which files should be written. The directory will be created if it doesn't exist.") - .build()); - props.add(CONFLICT_RESOLUTION); - props.add(APPEND_MODE); - props.add(WRITING_STRATEGY); - props.add(BLOCK_SIZE); - props.add(BUFFER_SIZE); - props.add(REPLICATION_FACTOR); - props.add(UMASK); - props.add(REMOTE_OWNER); - props.add(REMOTE_GROUP); - props.add(COMPRESSION_CODEC); - props.add(IGNORE_LOCALITY); - props.add(RESOURCE_TRANSFER_SOURCE); - props.add(FILE_RESOURCE_SERVICE); - return props; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/inotify/GetHDFSEvents.java b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/inotify/GetHDFSEvents.java index 9ad2cb427e42..26a2d83f90b8 100644 --- a/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/inotify/GetHDFSEvents.java +++ b/nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/inotify/GetHDFSEvents.java @@ -53,14 +53,13 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; +import java.util.stream.Stream; @TriggerSerially @TriggerWhenEmpty @@ -137,7 +136,21 @@ public class GetHDFSEvents extends AbstractHadoopProcessor { .description("A flow file with updated information about a specific event will be sent to this relationship.") .build(); - private static final Set RELATIONSHIPS = Collections.unmodifiableSet(new HashSet<>(Collections.singletonList(REL_SUCCESS))); + private static final List PROPERTIES = Stream.concat( + PARENT_PROPERTIES.stream(), + Stream.of( + POLL_DURATION, + HDFS_PATH_TO_WATCH, + IGNORE_HIDDEN_FILES, + EVENT_TYPES, + NUMBER_OF_RETRIES_FOR_POLL + ) + ).toList(); + + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS + ); + private static final String LAST_TX_ID = "last.tx.id"; private volatile long lastTxId = -1L; private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @@ -145,13 +158,7 @@ public class GetHDFSEvents extends AbstractHadoopProcessor { @Override protected List getSupportedPropertyDescriptors() { - List props = new ArrayList<>(properties); - props.add(POLL_DURATION); - props.add(HDFS_PATH_TO_WATCH); - props.add(IGNORE_HIDDEN_FILES); - props.add(EVENT_TYPES); - props.add(NUMBER_OF_RETRIES_FOR_POLL); - return Collections.unmodifiableList(props); + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-hashicorp-vault-bundle/nifi-hashicorp-vault-client-service/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultClientService.java b/nifi-extension-bundles/nifi-hashicorp-vault-bundle/nifi-hashicorp-vault-client-service/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultClientService.java index 7b836f65d3c9..627ae148f480 100644 --- a/nifi-extension-bundles/nifi-hashicorp-vault-bundle/nifi-hashicorp-vault-client-service/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultClientService.java +++ b/nifi-extension-bundles/nifi-hashicorp-vault-bundle/nifi-hashicorp-vault-client-service/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultClientService.java @@ -38,8 +38,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -58,15 +56,15 @@ ) public class StandardHashiCorpVaultClientService extends AbstractControllerService implements HashiCorpVaultClientService { - private static List PROPERTIES = Collections.unmodifiableList(Arrays.asList( - CONFIGURATION_STRATEGY, - VAULT_URI, - VAULT_AUTHENTICATION, - SSL_CONTEXT_SERVICE, - VAULT_PROPERTIES_FILES, - CONNECTION_TIMEOUT, - READ_TIMEOUT - )); + private static final List PROPERTIES = List.of( + CONFIGURATION_STRATEGY, + VAULT_URI, + VAULT_AUTHENTICATION, + SSL_CONTEXT_SERVICE, + VAULT_PROPERTIES_FILES, + CONNECTION_TIMEOUT, + READ_TIMEOUT + ); private HashiCorpVaultCommunicationService communicationService; diff --git a/nifi-extension-bundles/nifi-hazelcast-bundle/nifi-hazelcast-services/src/main/java/org/apache/nifi/hazelcast/services/cacheclient/HazelcastMapCacheClient.java b/nifi-extension-bundles/nifi-hazelcast-bundle/nifi-hazelcast-services/src/main/java/org/apache/nifi/hazelcast/services/cacheclient/HazelcastMapCacheClient.java index 9863acf5fd8e..ec11673ba6b5 100644 --- a/nifi-extension-bundles/nifi-hazelcast-bundle/nifi-hazelcast-services/src/main/java/org/apache/nifi/hazelcast/services/cacheclient/HazelcastMapCacheClient.java +++ b/nifi-extension-bundles/nifi-hazelcast-bundle/nifi-hazelcast-services/src/main/java/org/apache/nifi/hazelcast/services/cacheclient/HazelcastMapCacheClient.java @@ -36,9 +36,7 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -86,15 +84,11 @@ public class HazelcastMapCacheClient extends AbstractControllerService implement .build(); private static final long STARTING_REVISION = 1; - private static final List PROPERTY_DESCRIPTORS; - - static { - final List properties = new ArrayList<>(); - properties.add(HAZELCAST_CACHE_MANAGER); - properties.add(HAZELCAST_CACHE_NAME); - properties.add(HAZELCAST_ENTRY_TTL); - PROPERTY_DESCRIPTORS = Collections.unmodifiableList(properties); - } + private static final List PROPERTIES = List.of( + HAZELCAST_CACHE_MANAGER, + HAZELCAST_CACHE_NAME, + HAZELCAST_ENTRY_TTL + ); private volatile HazelcastCache cache = null; @@ -198,7 +192,7 @@ public void close() { @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } private String serializeCacheEntryKey(final S key, final Serializer serializer) throws IOException { diff --git a/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JndiJmsConnectionFactoryProperties.java b/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JndiJmsConnectionFactoryProperties.java index 13945e045049..f8960a0a085c 100644 --- a/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JndiJmsConnectionFactoryProperties.java +++ b/nifi-extension-bundles/nifi-jms-bundle/nifi-jms-processors/src/main/java/org/apache/nifi/jms/cf/JndiJmsConnectionFactoryProperties.java @@ -99,7 +99,7 @@ public class JndiJmsConnectionFactoryProperties { .sensitive(true) .build(); - private static final List PROPERTY_DESCRIPTORS = Arrays.asList( + private static final List PROPERTIES = List.of( JndiJmsConnectionFactoryProperties.JNDI_INITIAL_CONTEXT_FACTORY, JndiJmsConnectionFactoryProperties.JNDI_PROVIDER_URL, JndiJmsConnectionFactoryProperties.JNDI_CONNECTION_FACTORY_NAME, @@ -109,7 +109,7 @@ public class JndiJmsConnectionFactoryProperties { ); public static List getPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } public static PropertyDescriptor getDynamicPropertyDescriptor(final String propertyDescriptorName) { diff --git a/nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-3-service/src/main/java/org/apache/nifi/kafka/service/Kafka3ConnectionService.java b/nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-3-service/src/main/java/org/apache/nifi/kafka/service/Kafka3ConnectionService.java index 8b808efc2146..3b90b013eeac 100644 --- a/nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-3-service/src/main/java/org/apache/nifi/kafka/service/Kafka3ConnectionService.java +++ b/nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-3-service/src/main/java/org/apache/nifi/kafka/service/Kafka3ConnectionService.java @@ -214,7 +214,7 @@ public class Kafka3ConnectionService extends AbstractControllerService implement .defaultValue("5 sec") .build(); - private static final List PROPERTY_DESCRIPTORS = List.of( + private static final List PROPERTIES = List.of( BOOTSTRAP_SERVERS, SECURITY_PROTOCOL, SASL_MECHANISM, @@ -246,7 +246,7 @@ public void onEnabled(final ConfigurationContext configurationContext) { @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ExtractImageMetadata.java b/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ExtractImageMetadata.java index 89584381d14d..71f2cdd8b8df 100644 --- a/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ExtractImageMetadata.java +++ b/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/image/ExtractImageMetadata.java @@ -16,10 +16,7 @@ */ package org.apache.nifi.processors.image; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -37,7 +34,6 @@ import org.apache.nifi.processor.AbstractProcessor; import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; @@ -79,30 +75,23 @@ public class ExtractImageMetadata extends AbstractProcessor { .description("Any FlowFile that fails to have image metadata extracted will be routed to failure") .build(); - private Set relationships; - private List properties; + private static final List PROPERTIES = List.of( + MAX_NUMBER_OF_ATTRIBUTES + ); - @Override - protected void init(final ProcessorInitializationContext context) { - - final List properties = new ArrayList<>(); - properties.add(MAX_NUMBER_OF_ATTRIBUTES); - this.properties = Collections.unmodifiableList(properties); - - final Set relationships = new HashSet<>(); - relationships.add(SUCCESS); - relationships.add(FAILURE); - this.relationships = Collections.unmodifiableSet(relationships); - } + private static final Set RELATIONSHIPS = Set.of( + SUCCESS, + FAILURE + ); @Override public Set getRelationships() { - return this.relationships; + return RELATIONSHIPS; } @Override protected List getSupportedPropertyDescriptors() { - return this.properties; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/media/ExtractMediaMetadata.java b/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/media/ExtractMediaMetadata.java index 2e557b713a63..d67dbb44eb4d 100644 --- a/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/media/ExtractMediaMetadata.java +++ b/nifi-extension-bundles/nifi-media-bundle/nifi-media-processors/src/main/java/org/apache/nifi/processors/media/ExtractMediaMetadata.java @@ -18,10 +18,7 @@ import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -43,7 +40,6 @@ import org.apache.nifi.processor.AbstractProcessor; import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; @@ -119,37 +115,30 @@ public class ExtractMediaMetadata extends AbstractProcessor { .description("Any FlowFile that fails to have media metadata extracted will be routed to failure") .build(); - private Set relationships; - private List properties; + private static final List PROPERTIES = List.of( + MAX_NUMBER_OF_ATTRIBUTES, + MAX_ATTRIBUTE_LENGTH, + METADATA_KEY_FILTER, + METADATA_KEY_PREFIX + ); + + private static final Set RELATIONSHIPS = Set.of( + SUCCESS, + FAILURE + ); private final AtomicReference metadataKeyFilterRef = new AtomicReference<>(); private volatile AutoDetectParser autoDetectParser; - @Override - protected void init(final ProcessorInitializationContext context) { - - final List properties = new ArrayList<>(); - properties.add(MAX_NUMBER_OF_ATTRIBUTES); - properties.add(MAX_ATTRIBUTE_LENGTH); - properties.add(METADATA_KEY_FILTER); - properties.add(METADATA_KEY_PREFIX); - this.properties = Collections.unmodifiableList(properties); - - final Set relationships = new HashSet<>(); - relationships.add(SUCCESS); - relationships.add(FAILURE); - this.relationships = Collections.unmodifiableSet(relationships); - } - @Override public Set getRelationships() { - return this.relationships; + return RELATIONSHIPS; } @Override protected List getSupportedPropertyDescriptors() { - return this.properties; + return PROPERTIES; } @SuppressWarnings("unused") diff --git a/nifi-extension-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java b/nifi-extension-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java index 7d2ec672e8bb..7b4b0c26445c 100644 --- a/nifi-extension-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java +++ b/nifi-extension-bundles/nifi-mongodb-bundle/nifi-mongodb-services/src/main/java/org/apache/nifi/mongodb/MongoDBControllerService.java @@ -23,7 +23,7 @@ import com.mongodb.WriteConcern; import com.mongodb.client.MongoClients; import com.mongodb.client.MongoDatabase; -import java.util.ArrayList; + import java.util.Arrays; import java.util.List; import java.io.UnsupportedEncodingException; @@ -58,16 +58,14 @@ public void onEnabled(final ConfigurationContext context) { this.mongoClient = createClient(context, this.mongoClient); } - static List descriptors = new ArrayList<>(); - - static { - descriptors.add(URI); - descriptors.add(DB_USER); - descriptors.add(DB_PASSWORD); - descriptors.add(SSL_CONTEXT_SERVICE); - descriptors.add(CLIENT_AUTH); - descriptors.add(WRITE_CONCERN); - } + private static final List PROPERTIES = List.of( + URI, + DB_USER, + DB_PASSWORD, + SSL_CONTEXT_SERVICE, + CLIENT_AUTH, + WRITE_CONCERN + ); protected MongoClient mongoClient; private String writeConcernProperty; @@ -182,7 +180,7 @@ public WriteConcern getWriteConcern() { @Override protected List getSupportedPropertyDescriptors() { - return descriptors; + return PROPERTIES; } @OnDisabled diff --git a/nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-processors/src/main/java/org/apache/nifi/parquet/ParquetReader.java b/nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-processors/src/main/java/org/apache/nifi/parquet/ParquetReader.java index e84f17ceea6a..78736a47fa92 100644 --- a/nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-processors/src/main/java/org/apache/nifi/parquet/ParquetReader.java +++ b/nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-processors/src/main/java/org/apache/nifi/parquet/ParquetReader.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.List; import java.util.Map; import org.apache.hadoop.conf.Configuration; @@ -41,6 +40,10 @@ "The schema will come from the Parquet data itself.") public class ParquetReader extends AbstractControllerService implements RecordReaderFactory { + private static final List PROPERTIES = List.of( + ParquetUtils.AVRO_READ_COMPATIBILITY + ); + @Override public RecordReader createRecordReader(final Map variables, final InputStream in, final long inputLength, final ComponentLog logger) throws IOException { final Configuration conf = new Configuration(); @@ -51,8 +54,6 @@ public RecordReader createRecordReader(final Map variables, fina @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(ParquetUtils.AVRO_READ_COMPATIBILITY); - return properties; + return PROPERTIES; } } diff --git a/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPrivateKeyService.java b/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPrivateKeyService.java index c1251e5e098b..198bbf202824 100644 --- a/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPrivateKeyService.java +++ b/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPrivateKeyService.java @@ -52,7 +52,6 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -95,7 +94,7 @@ public class StandardPGPPrivateKeyService extends AbstractControllerService impl private static final Charset KEY_CHARSET = StandardCharsets.US_ASCII; - private static final List DESCRIPTORS = Arrays.asList( + private static final List PROPERTIES = List.of( KEYRING_FILE, KEYRING, KEY_PASSWORD @@ -154,7 +153,7 @@ public Optional findPrivateKey(final long keyIdentifier) { */ @Override protected List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } /** diff --git a/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPublicKeyService.java b/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPublicKeyService.java index 0aac1c2b14d1..e722c9eff178 100644 --- a/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPublicKeyService.java +++ b/nifi-extension-bundles/nifi-pgp-bundle/nifi-pgp-service/src/main/java/org/apache/nifi/pgp/service/standard/StandardPGPPublicKeyService.java @@ -48,7 +48,6 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -84,7 +83,7 @@ public class StandardPGPPublicKeyService extends AbstractControllerService imple private static final boolean PARALLEL_DISABLED = false; - private static final List DESCRIPTORS = Arrays.asList( + private static final List PROPERTIES = List.of( KEYRING_FILE, KEYRING ); @@ -135,7 +134,7 @@ public Optional findPublicKey(final String search) { */ @Override protected List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } /** diff --git a/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/SimpleRedisDistributedMapCacheClientService.java b/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/SimpleRedisDistributedMapCacheClientService.java index 999729855ce2..d33ea94939f8 100644 --- a/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/SimpleRedisDistributedMapCacheClientService.java +++ b/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-extensions/src/main/java/org/apache/nifi/redis/service/SimpleRedisDistributedMapCacheClientService.java @@ -35,8 +35,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -50,13 +48,10 @@ "This service is intended to be used when a non-atomic DistributedMapCacheClient is required.") public class SimpleRedisDistributedMapCacheClientService extends AbstractControllerService implements DistributedMapCacheClient { - static final List PROPERTY_DESCRIPTORS; - static { - final List props = new ArrayList<>(); - props.add(REDIS_CONNECTION_POOL); - props.add(TTL); - PROPERTY_DESCRIPTORS = Collections.unmodifiableList(props); - } + private static final List PROPERTIES = List.of( + REDIS_CONNECTION_POOL, + TTL + ); private volatile RedisConnectionPool redisConnectionPool; private Long ttl; @@ -67,7 +62,7 @@ protected Long getTtl() { @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-utils/src/main/java/org/apache/nifi/redis/util/RedisUtils.java b/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-utils/src/main/java/org/apache/nifi/redis/util/RedisUtils.java index 18cb5325de99..0bd1944e8865 100644 --- a/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-utils/src/main/java/org/apache/nifi/redis/util/RedisUtils.java +++ b/nifi-extension-bundles/nifi-redis-bundle/nifi-redis-utils/src/main/java/org/apache/nifi/redis/util/RedisUtils.java @@ -48,7 +48,6 @@ import javax.net.ssl.SSLContext; import java.time.Duration; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.concurrent.TimeUnit; @@ -298,34 +297,31 @@ public class RedisUtils { .identifiesControllerService(SSLContextProvider.class) .build(); - public static final List REDIS_CONNECTION_PROPERTY_DESCRIPTORS; - static { - final List props = new ArrayList<>(); - props.add(RedisUtils.REDIS_MODE); - props.add(RedisUtils.CONNECTION_STRING); - props.add(RedisUtils.DATABASE); - props.add(RedisUtils.COMMUNICATION_TIMEOUT); - props.add(RedisUtils.CLUSTER_MAX_REDIRECTS); - props.add(RedisUtils.SENTINEL_MASTER); - props.add(RedisUtils.USERNAME); - props.add(RedisUtils.PASSWORD); - props.add(RedisUtils.SENTINEL_USERNAME); - props.add(RedisUtils.SENTINEL_PASSWORD); - props.add(RedisUtils.SSL_CONTEXT_SERVICE); - props.add(RedisUtils.POOL_MAX_TOTAL); - props.add(RedisUtils.POOL_MAX_IDLE); - props.add(RedisUtils.POOL_MIN_IDLE); - props.add(RedisUtils.POOL_BLOCK_WHEN_EXHAUSTED); - props.add(RedisUtils.POOL_MAX_WAIT_TIME); - props.add(RedisUtils.POOL_MIN_EVICTABLE_IDLE_TIME); - props.add(RedisUtils.POOL_TIME_BETWEEN_EVICTION_RUNS); - props.add(RedisUtils.POOL_NUM_TESTS_PER_EVICTION_RUN); - props.add(RedisUtils.POOL_TEST_ON_CREATE); - props.add(RedisUtils.POOL_TEST_ON_BORROW); - props.add(RedisUtils.POOL_TEST_ON_RETURN); - props.add(RedisUtils.POOL_TEST_WHILE_IDLE); - REDIS_CONNECTION_PROPERTY_DESCRIPTORS = Collections.unmodifiableList(props); - } + public static final List REDIS_CONNECTION_PROPERTY_DESCRIPTORS = List.of( + RedisUtils.REDIS_MODE, + RedisUtils.CONNECTION_STRING, + RedisUtils.DATABASE, + RedisUtils.COMMUNICATION_TIMEOUT, + RedisUtils.CLUSTER_MAX_REDIRECTS, + RedisUtils.SENTINEL_MASTER, + RedisUtils.USERNAME, + RedisUtils.PASSWORD, + RedisUtils.SENTINEL_USERNAME, + RedisUtils.SENTINEL_PASSWORD, + RedisUtils.SSL_CONTEXT_SERVICE, + RedisUtils.POOL_MAX_TOTAL, + RedisUtils.POOL_MAX_IDLE, + RedisUtils.POOL_MIN_IDLE, + RedisUtils.POOL_BLOCK_WHEN_EXHAUSTED, + RedisUtils.POOL_MAX_WAIT_TIME, + RedisUtils.POOL_MIN_EVICTABLE_IDLE_TIME, + RedisUtils.POOL_TIME_BETWEEN_EVICTION_RUNS, + RedisUtils.POOL_NUM_TESTS_PER_EVICTION_RUN, + RedisUtils.POOL_TEST_ON_CREATE, + RedisUtils.POOL_TEST_ON_BORROW, + RedisUtils.POOL_TEST_ON_RETURN, + RedisUtils.POOL_TEST_WHILE_IDLE + ); public static RedisConfig createRedisConfig(final PropertyContext context) { final RedisType redisType = RedisType.fromDisplayName(context.getProperty(RedisUtils.REDIS_MODE).getValue()); diff --git a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/AvroSchemaRegistry.java b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/AvroSchemaRegistry.java index f2ad95989564..ec61209371cd 100644 --- a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/AvroSchemaRegistry.java +++ b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/AvroSchemaRegistry.java @@ -25,19 +25,15 @@ import org.apache.nifi.components.ValidationContext; import org.apache.nifi.components.ValidationResult; import org.apache.nifi.controller.AbstractControllerService; -import org.apache.nifi.controller.ControllerServiceInitializationContext; import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.processor.util.StandardValidators; -import org.apache.nifi.reporting.InitializationException; import org.apache.nifi.schema.access.SchemaField; import org.apache.nifi.schema.access.SchemaNotFoundException; import org.apache.nifi.serialization.record.RecordSchema; import org.apache.nifi.serialization.record.SchemaIdentifier; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.EnumSet; import java.util.HashSet; import java.util.List; @@ -67,16 +63,9 @@ public class AvroSchemaRegistry extends AbstractControllerService implements Sch .required(true) .build(); - private List propertyDescriptors = new ArrayList<>(); - - - @Override - protected void init(ControllerServiceInitializationContext config) throws InitializationException { - super.init(config); - List _propertyDescriptors = new ArrayList<>(); - _propertyDescriptors.add(VALIDATE_FIELD_NAMES); - propertyDescriptors = Collections.unmodifiableList(_propertyDescriptors); - } + private static final List PROPERTIES = List.of( + VALIDATE_FIELD_NAMES + ); @Override public void onPropertyModified(final PropertyDescriptor descriptor, final String oldValue, final String newValue) { @@ -143,7 +132,7 @@ public RecordSchema retrieveSchema(final SchemaIdentifier schemaIdentifier) thro @Override protected List getSupportedPropertyDescriptors() { - return propertyDescriptors; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java index 184059406a1d..353ef1edca5b 100644 --- a/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java +++ b/nifi-extension-bundles/nifi-registry-bundle/nifi-registry-service/src/main/java/org/apache/nifi/schemaregistry/services/StandardJsonSchemaRegistry.java @@ -34,7 +34,6 @@ import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -59,7 +58,9 @@ expressionLanguageScope = ExpressionLanguageScope.NONE) public class StandardJsonSchemaRegistry extends AbstractControllerService implements JsonSchemaRegistry, JsonSchemaRegistryComponent { - private static final List PROPERTY_DESCRIPTORS = Collections.singletonList(SCHEMA_VERSION); + private static final List PROPERTIES = List.of( + SCHEMA_VERSION + ); private final ConcurrentMap jsonSchemas; private final ConcurrentMap schemaFactories; @@ -142,7 +143,7 @@ public JsonSchema retrieveSchema(final String schemaName) throws SchemaNotFoundE @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/sink/SiteToSiteReportingRecordSink.java b/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/sink/SiteToSiteReportingRecordSink.java index 65bce7b083a6..e159095ee12c 100644 --- a/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/sink/SiteToSiteReportingRecordSink.java +++ b/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/sink/SiteToSiteReportingRecordSink.java @@ -18,8 +18,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.nifi.annotation.documentation.CapabilityDescription; @@ -52,31 +50,31 @@ @CapabilityDescription("Provides a service to write records using a configured RecordSetWriter over a Site-to-Site connection.") public class SiteToSiteReportingRecordSink extends AbstractControllerService implements RecordSinkService { - private List properties; + private static final List PROPERTIES = List.of( + RECORD_WRITER_FACTORY, + SiteToSiteUtils.DESTINATION_URL, + SiteToSiteUtils.PORT_NAME, + SiteToSiteUtils.SSL_CONTEXT, + SiteToSiteUtils.INSTANCE_URL, + SiteToSiteUtils.COMPRESS, + SiteToSiteUtils.TIMEOUT, + SiteToSiteUtils.BATCH_SIZE, + SiteToSiteUtils.TRANSPORT_PROTOCOL, + SiteToSiteUtils.PROXY_CONFIGURATION_SERVICE + ); + private volatile SiteToSiteClient siteToSiteClient; private volatile RecordSetWriterFactory writerFactory; private volatile StateManager stateManager; @Override protected void init(final ControllerServiceInitializationContext context) { - final List properties = new ArrayList<>(); - properties.add(RECORD_WRITER_FACTORY); - properties.add(SiteToSiteUtils.DESTINATION_URL); - properties.add(SiteToSiteUtils.PORT_NAME); - properties.add(SiteToSiteUtils.SSL_CONTEXT); - properties.add(SiteToSiteUtils.INSTANCE_URL); - properties.add(SiteToSiteUtils.COMPRESS); - properties.add(SiteToSiteUtils.TIMEOUT); - properties.add(SiteToSiteUtils.BATCH_SIZE); - properties.add(SiteToSiteUtils.TRANSPORT_PROTOCOL); - properties.add(SiteToSiteUtils.PROXY_CONFIGURATION_SERVICE); - this.properties = Collections.unmodifiableList(properties); this.stateManager = context.getStateManager(); } @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/services/slack/SlackRecordSink.java b/nifi-extension-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/services/slack/SlackRecordSink.java index f99cf56647f8..7ecab3c14b67 100644 --- a/nifi-extension-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/services/slack/SlackRecordSink.java +++ b/nifi-extension-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/services/slack/SlackRecordSink.java @@ -36,8 +36,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -93,19 +91,21 @@ public class SlackRecordSink extends AbstractControllerService implements Record .identifiesControllerService(WebClientServiceProvider.class) .build(); + private static final List PROPERTIES = List.of( + API_URL, + ACCESS_TOKEN, + CHANNEL_ID, + INPUT_CHARACTER_SET, + RECORD_WRITER_FACTORY, + WEB_SERVICE_CLIENT_PROVIDER + ); + private volatile RecordSetWriterFactory writerFactory; private SlackRestService service; @Override public List getSupportedPropertyDescriptors() { - return Collections.unmodifiableList(Arrays.asList( - API_URL, - ACCESS_TOKEN, - CHANNEL_ID, - INPUT_CHARACTER_SET, - RECORD_WRITER_FACTORY, - WEB_SERVICE_CLIENT_PROVIDER - )); + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/PutSmbFile.java b/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/PutSmbFile.java index 56014caad0c1..7290d87e73a8 100644 --- a/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/PutSmbFile.java +++ b/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/PutSmbFile.java @@ -48,7 +48,6 @@ import org.apache.nifi.processor.AbstractProcessor; import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.ProcessSession; -import org.apache.nifi.processor.ProcessorInitializationContext; import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; @@ -171,43 +170,39 @@ public class PutSmbFile extends AbstractProcessor { .description("Files that could not be written to the output network path for some reason are transferred to this relationship") .build(); - private List descriptors; - - private Set relationships; + private static final List PROPERTIES = List.of( + HOSTNAME, + SHARE, + DIRECTORY, + DOMAIN, + USERNAME, + PASSWORD, + CREATE_DIRS, + SHARE_ACCESS, + CONFLICT_RESOLUTION, + BATCH_SIZE, + RENAME_SUFFIX, + SMB_DIALECT, + USE_ENCRYPTION, + ENABLE_DFS, + TIMEOUT); + + private static final Set RELATIONSHIPS = Set.of( + REL_SUCCESS, + REL_FAILURE + ); private SMBClient smbClient = null; // this gets synchronized when the `connect` method is called private Set sharedAccess; - @Override - protected void init(final ProcessorInitializationContext context) { - this.descriptors = List.of( - HOSTNAME, - SHARE, - DIRECTORY, - DOMAIN, - USERNAME, - PASSWORD, - CREATE_DIRS, - SHARE_ACCESS, - CONFLICT_RESOLUTION, - BATCH_SIZE, - RENAME_SUFFIX, - SMB_DIALECT, - USE_ENCRYPTION, - ENABLE_DFS, - TIMEOUT); - - this.relationships = Set.of(REL_SUCCESS, REL_FAILURE); - } - @Override public Set getRelationships() { - return this.relationships; + return RELATIONSHIPS; } @Override public final List getSupportedPropertyDescriptors() { - return descriptors; + return PROPERTIES; } @OnScheduled diff --git a/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientProviderService.java b/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientProviderService.java index ebffb816ec80..359b29d80f48 100644 --- a/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientProviderService.java +++ b/nifi-extension-bundles/nifi-smb-bundle/nifi-smb-smbj-client/src/main/java/org/apache/nifi/services/smb/SmbjClientProviderService.java @@ -32,10 +32,8 @@ import java.io.IOException; import java.net.URI; -import java.util.Collections; import java.util.List; -import static java.util.Arrays.asList; import static org.apache.nifi.processor.util.StandardValidators.NON_BLANK_VALIDATOR; import static org.apache.nifi.processor.util.StandardValidators.NON_EMPTY_VALIDATOR; import static org.apache.nifi.processor.util.StandardValidators.PORT_VALIDATOR; @@ -103,19 +101,18 @@ public class SmbjClientProviderService extends AbstractControllerService impleme .addValidator(NON_BLANK_VALIDATOR) .build(); - private static final List PROPERTIES = Collections - .unmodifiableList(asList( - HOSTNAME, - PORT, - SHARE, - USERNAME, - PASSWORD, - DOMAIN, - SMB_DIALECT, - USE_ENCRYPTION, - ENABLE_DFS, - TIMEOUT - )); + private static final List PROPERTIES = List.of( + HOSTNAME, + PORT, + SHARE, + USERNAME, + PASSWORD, + DOMAIN, + SMB_DIALECT, + USE_ENCRYPTION, + ENABLE_DFS, + TIMEOUT + ); private SMBClient smbClient; private AuthenticationContext authenticationContext; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-db-schema-registry-bundle/nifi-db-schema-registry-service/src/main/java/org/apache/nifi/db/schemaregistry/DatabaseTableSchemaRegistry.java b/nifi-extension-bundles/nifi-standard-services/nifi-db-schema-registry-bundle/nifi-db-schema-registry-service/src/main/java/org/apache/nifi/db/schemaregistry/DatabaseTableSchemaRegistry.java index caf5888b11a8..3b95a3a27b0b 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-db-schema-registry-bundle/nifi-db-schema-registry-service/src/main/java/org/apache/nifi/db/schemaregistry/DatabaseTableSchemaRegistry.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-db-schema-registry-bundle/nifi-db-schema-registry-service/src/main/java/org/apache/nifi/db/schemaregistry/DatabaseTableSchemaRegistry.java @@ -40,8 +40,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Optional; @@ -84,11 +82,11 @@ public class DatabaseTableSchemaRegistry extends AbstractControllerService imple .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); - protected List propDescriptors = Collections.unmodifiableList(Arrays.asList( - DBCP_SERVICE, - CATALOG_NAME, - SCHEMA_NAME - )); + private static final List PROPERTIES = List.of( + DBCP_SERVICE, + CATALOG_NAME, + SCHEMA_NAME + ); private volatile DBCPService dbcpService; private volatile String dbCatalogName; @@ -96,7 +94,7 @@ public class DatabaseTableSchemaRegistry extends AbstractControllerService imple @Override protected List getSupportedPropertyDescriptors() { - return propDescriptors; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/record/sink/db/DatabaseRecordSink.java b/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/record/sink/db/DatabaseRecordSink.java index beb606f1f165..95fc3383eef4 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/record/sink/db/DatabaseRecordSink.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-dbcp-service/src/main/java/org/apache/nifi/record/sink/db/DatabaseRecordSink.java @@ -25,7 +25,6 @@ import org.apache.nifi.context.PropertyContext; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.controller.ConfigurationContext; -import org.apache.nifi.controller.ControllerServiceInitializationContext; import org.apache.nifi.dbcp.DBCPService; import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.processor.util.StandardValidators; @@ -48,7 +47,6 @@ import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -162,31 +160,25 @@ public class DatabaseRecordSink extends AbstractControllerService implements Rec .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .build(); - private List properties; + private static final List PROPERTIES = List.of( + DBCP_SERVICE, + CATALOG_NAME, + SCHEMA_NAME, + TABLE_NAME, + TRANSLATE_FIELD_NAMES, + UNMATCHED_FIELD_BEHAVIOR, + UNMATCHED_COLUMN_BEHAVIOR, + QUOTED_IDENTIFIERS, + QUOTED_TABLE_IDENTIFIER, + QUERY_TIMEOUT + ); + private volatile ConfigurationContext context; private volatile DBCPService dbcpService; - @Override - protected void init(final ControllerServiceInitializationContext context) { - final List properties = new ArrayList<>(); - properties.add(DBCP_SERVICE); - properties.add(CATALOG_NAME); - properties.add(SCHEMA_NAME); - properties.add(TABLE_NAME); - properties.add(TRANSLATE_FIELD_NAMES); - properties.add(UNMATCHED_FIELD_BEHAVIOR); - properties.add(UNMATCHED_COLUMN_BEHAVIOR); - properties.add(QUOTED_IDENTIFIERS); - properties.add(QUOTED_TABLE_IDENTIFIER); - - properties.add(QUERY_TIMEOUT); - - this.properties = Collections.unmodifiableList(properties); - } - @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-hikari-dbcp-service/src/main/java/org/apache/nifi/dbcp/HikariCPConnectionPool.java b/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-hikari-dbcp-service/src/main/java/org/apache/nifi/dbcp/HikariCPConnectionPool.java index 59413b71e455..ef0290d3a93c 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-hikari-dbcp-service/src/main/java/org/apache/nifi/dbcp/HikariCPConnectionPool.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-dbcp-service-bundle/nifi-hikari-dbcp-service/src/main/java/org/apache/nifi/dbcp/HikariCPConnectionPool.java @@ -50,7 +50,6 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Properties; @@ -206,31 +205,26 @@ public class HikariCPConnectionPool extends AbstractControllerService implements .required(false) .build(); - private static final List properties; - - static { - final List props = new ArrayList<>(); - props.add(DATABASE_URL); - props.add(DB_DRIVERNAME); - props.add(DB_DRIVER_LOCATION); - props.add(KERBEROS_USER_SERVICE); - props.add(DB_USER); - props.add(DB_PASSWORD); - props.add(MAX_WAIT_TIME); - props.add(MAX_TOTAL_CONNECTIONS); - props.add(VALIDATION_QUERY); - props.add(MIN_IDLE); - props.add(MAX_CONN_LIFETIME); - - properties = Collections.unmodifiableList(props); - } + private static final List PROPERTIES = List.of( + DATABASE_URL, + DB_DRIVERNAME, + DB_DRIVER_LOCATION, + KERBEROS_USER_SERVICE, + DB_USER, + DB_PASSWORD, + MAX_WAIT_TIME, + MAX_TOTAL_CONNECTIONS, + VALIDATION_QUERY, + MIN_IDLE, + MAX_CONN_LIFETIME + ); private volatile HikariDataSource dataSource; private volatile KerberosUser kerberosUser; @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/MapCacheClientService.java b/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/MapCacheClientService.java index 9943a58ba592..55b2a75556bf 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/MapCacheClientService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/MapCacheClientService.java @@ -36,7 +36,6 @@ import org.apache.nifi.ssl.SSLContextProvider; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -82,6 +81,13 @@ public class MapCacheClientService extends AbstractControllerService implements .defaultValue("30 secs") .build(); + private static final List PROPERTIES = List.of( + HOSTNAME, + PORT, + SSL_CONTEXT_SERVICE, + COMMUNICATIONS_TIMEOUT + ); + private volatile NettyMapCacheClient cacheClient = null; /** @@ -91,12 +97,7 @@ public class MapCacheClientService extends AbstractControllerService implements @Override protected List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(HOSTNAME); - descriptors.add(PORT); - descriptors.add(SSL_CONTEXT_SERVICE); - descriptors.add(COMMUNICATIONS_TIMEOUT); - return descriptors; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/SetCacheClientService.java b/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/SetCacheClientService.java index dd362a37762b..6f38704d9ec8 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/SetCacheClientService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-client-service/src/main/java/org/apache/nifi/distributed/cache/client/SetCacheClientService.java @@ -32,7 +32,6 @@ import org.apache.nifi.ssl.SSLContextProvider; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -71,6 +70,13 @@ public class SetCacheClientService extends AbstractControllerService implements .defaultValue("30 secs") .build(); + private static final List PROPERTIES = List.of( + HOSTNAME, + PORT, + SSL_CONTEXT_SERVICE, + COMMUNICATIONS_TIMEOUT + ); + private volatile NettySetCacheClient cacheClient = null; /** @@ -80,12 +86,7 @@ public class SetCacheClientService extends AbstractControllerService implements @Override protected List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(HOSTNAME); - descriptors.add(PORT); - descriptors.add(SSL_CONTEXT_SERVICE); - descriptors.add(COMMUNICATIONS_TIMEOUT); - return descriptors; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-file-resource-service-bundle/nifi-file-resource-service/src/main/java/org/apache/nifi/fileresource/service/StandardFileResourceService.java b/nifi-extension-bundles/nifi-standard-services/nifi-file-resource-service-bundle/nifi-file-resource-service/src/main/java/org/apache/nifi/fileresource/service/StandardFileResourceService.java index 24e543d09063..2747ca3a1c8d 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-file-resource-service-bundle/nifi-file-resource-service/src/main/java/org/apache/nifi/fileresource/service/StandardFileResourceService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-file-resource-service-bundle/nifi-file-resource-service/src/main/java/org/apache/nifi/fileresource/service/StandardFileResourceService.java @@ -39,7 +39,6 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -66,7 +65,7 @@ public class StandardFileResourceService extends AbstractControllerService imple .addValidator(StandardValidators.NON_BLANK_VALIDATOR) .build(); - private static final List PROPERTIES = Arrays.asList( + private static final List PROPERTIES = List.of( FILE_PATH ); diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-hadoop-dbcp-service-bundle/nifi-hadoop-dbcp-service/src/main/java/org/apache/nifi/dbcp/HadoopDBCPConnectionPool.java b/nifi-extension-bundles/nifi-standard-services/nifi-hadoop-dbcp-service-bundle/nifi-hadoop-dbcp-service/src/main/java/org/apache/nifi/dbcp/HadoopDBCPConnectionPool.java index 135dc12dcf57..1c362f01f870 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-hadoop-dbcp-service-bundle/nifi-hadoop-dbcp-service/src/main/java/org/apache/nifi/dbcp/HadoopDBCPConnectionPool.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-hadoop-dbcp-service-bundle/nifi-hadoop-dbcp-service/src/main/java/org/apache/nifi/dbcp/HadoopDBCPConnectionPool.java @@ -35,7 +35,6 @@ import org.apache.nifi.components.resource.ResourceCardinality; import org.apache.nifi.components.resource.ResourceType; import org.apache.nifi.controller.ConfigurationContext; -import org.apache.nifi.controller.ControllerServiceInitializationContext; import org.apache.nifi.dbcp.utils.DBCPProperties; import org.apache.nifi.dbcp.utils.DataSourceConfiguration; import org.apache.nifi.expression.ExpressionLanguageScope; @@ -49,7 +48,6 @@ import java.sql.DriverManager; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Map; @@ -115,35 +113,30 @@ public class HadoopDBCPConnectionPool extends AbstractDBCPConnectionPool { .dynamicallyModifiesClasspath(true) .build(); - private List properties; + private static final List PROPERTIES = List.of( + DATABASE_URL, + DB_DRIVERNAME, + DB_DRIVER_LOCATION, + HADOOP_CONFIGURATION_RESOURCES, + KERBEROS_USER_SERVICE, + DB_USER, + DB_PASSWORD, + MAX_WAIT_TIME, + MAX_TOTAL_CONNECTIONS, + VALIDATION_QUERY, + MIN_IDLE, + MAX_IDLE, + MAX_CONN_LIFETIME, + EVICTION_RUN_PERIOD, + MIN_EVICTABLE_IDLE_TIME, + SOFT_MIN_EVICTABLE_IDLE_TIME + ); private volatile Boolean foundHadoopDependencies; // Holder of cached Configuration information so validation does not reload the same config over and over private final AtomicReference validationResourceHolder = new AtomicReference<>(null); - @Override - protected void init(final ControllerServiceInitializationContext context) { - properties = Arrays.asList( - DATABASE_URL, - DB_DRIVERNAME, - DB_DRIVER_LOCATION, - HADOOP_CONFIGURATION_RESOURCES, - KERBEROS_USER_SERVICE, - DB_USER, - DB_PASSWORD, - MAX_WAIT_TIME, - MAX_TOTAL_CONNECTIONS, - VALIDATION_QUERY, - MIN_IDLE, - MAX_IDLE, - MAX_CONN_LIFETIME, - EVICTION_RUN_PERIOD, - MIN_EVICTABLE_IDLE_TIME, - SOFT_MIN_EVICTABLE_IDLE_TIME - ); - } - @Override public void migrateProperties(final PropertyConfiguration config) { config.removeProperty("Kerberos Principal"); @@ -154,7 +147,7 @@ public void migrateProperties(final PropertyConfiguration config) { @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java b/nifi-extension-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java index 4518f8473c3d..27e7dc108cae 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-http-context-map-bundle/nifi-http-context-map/src/main/java/org/apache/nifi/http/StandardHttpContextMap.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.http; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -66,6 +65,11 @@ public class StandardHttpContextMap extends AbstractControllerService implements .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) .build(); + private static final List PROPERTIES = List.of( + MAX_OUTSTANDING_REQUESTS, + REQUEST_EXPIRATION + ); + private static final long CLEANUP_MAX_DELAY_NANOS = 5_000_000_000L; private final ConcurrentMap wrapperMap = new ConcurrentHashMap<>(); @@ -76,10 +80,7 @@ public class StandardHttpContextMap extends AbstractControllerService implements @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(2); - properties.add(MAX_OUTSTANDING_REQUESTS); - properties.add(REQUEST_EXPIRATION); - return properties; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-key-service-bundle/nifi-key-service/src/main/java/org/apache/nifi/key/service/StandardPrivateKeyService.java b/nifi-extension-bundles/nifi-standard-services/nifi-key-service-bundle/nifi-key-service/src/main/java/org/apache/nifi/key/service/StandardPrivateKeyService.java index b1a1ead53a58..b74f1506f2d6 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-key-service-bundle/nifi-key-service/src/main/java/org/apache/nifi/key/service/StandardPrivateKeyService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-key-service-bundle/nifi-key-service/src/main/java/org/apache/nifi/key/service/StandardPrivateKeyService.java @@ -43,7 +43,6 @@ import java.nio.charset.StandardCharsets; import java.security.PrivateKey; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.concurrent.atomic.AtomicReference; @@ -80,7 +79,7 @@ public class StandardPrivateKeyService extends AbstractControllerService impleme .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); - private static final List DESCRIPTORS = Arrays.asList( + private static final List PROPERTIES = List.of( KEY_FILE, KEY, KEY_PASSWORD @@ -142,7 +141,7 @@ public void onDisabled() { */ @Override protected List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } /** diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java index 6bd043187bc1..36eb0cb2f8b5 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java @@ -21,7 +21,6 @@ import java.io.OutputStream; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -80,6 +79,11 @@ public class DistributedMapCacheLookupService extends AbstractControllerService .defaultValue(StandardCharsets.UTF_8.displayName()) .build(); + private static final List PROPERTIES = List.of( + PROP_DISTRIBUTED_CACHE_SERVICE, + CHARACTER_ENCODING + ); + private static Set getStandardCharsetNames() { return STANDARD_CHARSETS.stream().map(c -> c.displayName()).collect(Collectors.toSet()); } @@ -92,10 +96,7 @@ public void onEnabled(final ConfigurationContext context) { @Override protected List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(PROP_DISTRIBUTED_CACHE_SERVICE); - descriptors.add(CHARACTER_ENCODING); - return descriptors; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java index 4a8ed532b718..7b3d499ec23b 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java @@ -212,33 +212,29 @@ public class RestLookupService extends AbstractControllerService implements Reco static final String BODY_KEY = "request.body"; static final String METHOD_KEY = "request.method"; - static final List DESCRIPTORS; - static final Set KEYS; + private static final List PROPERTIES = List.of( + URL, + RECORD_READER, + RECORD_PATH, + RESPONSE_HANDLING_STRATEGY, + SSL_CONTEXT_SERVICE, + AUTHENTICATION_STRATEGY, + OAUTH2_ACCESS_TOKEN_PROVIDER, + PROXY_CONFIGURATION_SERVICE, + PROP_BASIC_AUTH_USERNAME, + PROP_BASIC_AUTH_PASSWORD, + PROP_DIGEST_AUTH, + PROP_CONNECT_TIMEOUT, + PROP_READ_TIMEOUT + ); + + static final Set KEYS = Set.of(); static final List VALID_VERBS = Arrays.asList("delete", "get", "post", "put"); - static { - DESCRIPTORS = Collections.unmodifiableList(Arrays.asList( - URL, - RECORD_READER, - RECORD_PATH, - RESPONSE_HANDLING_STRATEGY, - SSL_CONTEXT_SERVICE, - AUTHENTICATION_STRATEGY, - OAUTH2_ACCESS_TOKEN_PROVIDER, - PROXY_CONFIGURATION_SERVICE, - PROP_BASIC_AUTH_USERNAME, - PROP_BASIC_AUTH_PASSWORD, - PROP_DIGEST_AUTH, - PROP_CONNECT_TIMEOUT, - PROP_READ_TIMEOUT - )); - KEYS = Collections.emptySet(); - } - @Override protected List getSupportedPropertyDescriptors() { - return DESCRIPTORS; + return PROPERTIES; } private volatile ProxyConfigurationService proxyConfigurationService; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java index 7e16eb542679..3473a694ad63 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/configuration2/CommonsConfigurationLookupService.java @@ -30,7 +30,6 @@ import org.apache.nifi.components.resource.ResourceType; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.controller.ConfigurationContext; -import org.apache.nifi.controller.ControllerServiceInitializationContext; import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.lookup.LookupFailureException; import org.apache.nifi.lookup.StringLookupService; @@ -38,7 +37,6 @@ import java.io.File; import java.lang.reflect.ParameterizedType; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; @@ -69,9 +67,12 @@ public abstract class CommonsConfigurationLookupService PROPERTIES = List.of( + CONFIGURATION_FILE + ); + private final Class resultClass = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; - private List properties; private volatile ReloadingFileBasedConfigurationBuilder builder; @@ -88,14 +89,7 @@ private Configuration getConfiguration() throws LookupFailureException { @Override protected List getSupportedPropertyDescriptors() { - return properties; - } - - @Override - protected void init(final ControllerServiceInitializationContext context) throws InitializationException { - final List properties = new ArrayList<>(); - properties.add(CONFIGURATION_FILE); - this.properties = Collections.unmodifiableList(properties); + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/AbstractDatabaseLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/AbstractDatabaseLookupService.java index 1dff38bdb0e7..82c2d79f415b 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/AbstractDatabaseLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/AbstractDatabaseLookupService.java @@ -22,17 +22,16 @@ import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.processor.util.StandardValidators; -import java.util.Collections; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class AbstractDatabaseLookupService extends AbstractControllerService { static final String KEY = "key"; - static final Set REQUIRED_KEYS = Collections.unmodifiableSet(Stream.of(KEY).collect(Collectors.toSet())); + static final Set REQUIRED_KEYS = Set.of( + KEY + ); static final PropertyDescriptor DBCP_SERVICE = new PropertyDescriptor.Builder() .name("dbrecord-lookup-dbcp-service") diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/DatabaseRecordLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/DatabaseRecordLookupService.java index e4944a4bfb9c..ed44d9ee6c25 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/DatabaseRecordLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/DatabaseRecordLookupService.java @@ -40,9 +40,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -71,19 +69,21 @@ public class DatabaseRecordLookupService extends AbstractDatabaseLookupService i .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) .build(); + private static final List PROPERTIES = List.of( + DBCP_SERVICE, + TABLE_NAME, + LOOKUP_KEY_COLUMN, + LOOKUP_VALUE_COLUMNS, + CACHE_SIZE, + CLEAR_CACHE_ON_ENABLED, + CACHE_EXPIRATION, + DEFAULT_PRECISION, + DEFAULT_SCALE + ); + @Override protected void init(final ControllerServiceInitializationContext context) { - final List properties = new ArrayList<>(); - properties.add(DBCP_SERVICE); - properties.add(TABLE_NAME); - properties.add(LOOKUP_KEY_COLUMN); - properties.add(LOOKUP_VALUE_COLUMNS); - properties.add(CACHE_SIZE); - properties.add(CLEAR_CACHE_ON_ENABLED); - properties.add(CACHE_EXPIRATION); - properties.add(DEFAULT_PRECISION); - properties.add(DEFAULT_SCALE); - this.properties = Collections.unmodifiableList(properties); + this.properties = PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/SimpleDatabaseLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/SimpleDatabaseLookupService.java index 272a6f5a9a00..93169e897a03 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/SimpleDatabaseLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/db/SimpleDatabaseLookupService.java @@ -37,8 +37,6 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; @@ -62,17 +60,19 @@ public class SimpleDatabaseLookupService extends AbstractDatabaseLookupService i .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .build(); + private static final List PROPERTIES = List.of( + DBCP_SERVICE, + TABLE_NAME, + LOOKUP_KEY_COLUMN, + LOOKUP_VALUE_COLUMN, + CACHE_SIZE, + CLEAR_CACHE_ON_ENABLED, + CACHE_EXPIRATION + ); + @Override protected void init(final ControllerServiceInitializationContext context) { - final List properties = new ArrayList<>(); - properties.add(DBCP_SERVICE); - properties.add(TABLE_NAME); - properties.add(LOOKUP_KEY_COLUMN); - properties.add(LOOKUP_VALUE_COLUMN); - properties.add(CACHE_SIZE); - properties.add(CLEAR_CACHE_ON_ENABLED); - properties.add(CACHE_EXPIRATION); - this.properties = Collections.unmodifiableList(properties); + this.properties = PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java index c59bc85b8ded..dada28bb04b3 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/maxmind/IPLookupService.java @@ -50,7 +50,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -139,16 +138,18 @@ public class IPLookupService extends AbstractControllerService implements Record .required(true) .build(); + private static final List PROPERTIES = List.of( + GEO_DATABASE_FILE, + LOOKUP_CITY, + LOOKUP_ISP, + LOOKUP_DOMAIN, + LOOKUP_CONNECTION_TYPE, + LOOKUP_ANONYMOUS_IP_INFO + ); + @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(GEO_DATABASE_FILE); - properties.add(LOOKUP_CITY); - properties.add(LOOKUP_ISP); - properties.add(LOOKUP_DOMAIN); - properties.add(LOOKUP_CONNECTION_TYPE); - properties.add(LOOKUP_ANONYMOUS_IP_INFO); - return properties; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java b/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java index b26a58f422e8..da9865a14f5a 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java @@ -55,7 +55,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -210,7 +209,7 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH}; - private static final List PROPERTIES = Collections.unmodifiableList(Arrays.asList( + private static final List PROPERTIES = List.of( AUTHORIZATION_SERVER_URL, CLIENT_AUTHENTICATION_STRATEGY, GRANT_TYPE, @@ -226,7 +225,7 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService SSL_CONTEXT, HTTP_PROTOCOL_STRATEGY, ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS) - )); + ); private static final String AUTHORIZATION_HEADER = "Authorization"; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-bundle/nifi-proxy-configuration/src/main/java/org/apache/nifi/proxy/StandardProxyConfigurationService.java b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-bundle/nifi-proxy-configuration/src/main/java/org/apache/nifi/proxy/StandardProxyConfigurationService.java index 25fa7f131f1e..c2f640ab14b5 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-bundle/nifi-proxy-configuration/src/main/java/org/apache/nifi/proxy/StandardProxyConfigurationService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-bundle/nifi-proxy-configuration/src/main/java/org/apache/nifi/proxy/StandardProxyConfigurationService.java @@ -89,18 +89,20 @@ public class StandardProxyConfigurationService extends AbstractControllerService .sensitive(true) .build(); + private static final List PROPERTIES = List.of( + PROXY_TYPE, + SOCKS_VERSION, + PROXY_SERVER_HOST, + PROXY_SERVER_PORT, + PROXY_USER_NAME, + PROXY_USER_PASSWORD + ); + private volatile ProxyConfiguration configuration = ProxyConfiguration.DIRECT_CONFIGURATION; @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(PROXY_TYPE); - properties.add(SOCKS_VERSION); - properties.add(PROXY_SERVER_HOST); - properties.add(PROXY_SERVER_PORT); - properties.add(PROXY_USER_NAME); - properties.add(PROXY_USER_PASSWORD); - return properties; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/ReaderLookup.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/ReaderLookup.java index 279cede8b010..30f0b6b10f44 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/ReaderLookup.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/ReaderLookup.java @@ -68,13 +68,16 @@ public class ReaderLookup extends AbstractControllerService implements RecordRea .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); + private static final List PROPERTIES = List.of( + SERVICE_TO_USE + ); private volatile Map recordReaderFactoryMap; private volatile PropertyValue serviceToUseValue; @Override protected List getSupportedPropertyDescriptors() { - return Collections.singletonList(SERVICE_TO_USE); + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/RecordSetWriterLookup.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/RecordSetWriterLookup.java index cee608e2d8f6..48f18f44c43b 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/RecordSetWriterLookup.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/lookup/RecordSetWriterLookup.java @@ -67,6 +67,9 @@ public class RecordSetWriterLookup extends AbstractControllerService implements .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .build(); + private static final List PROPERTIES = List.of( + SERVICE_TO_USE + ); private volatile Map recordSetWriterFactoryMap; private volatile PropertyValue serviceToUseValue; @@ -82,7 +85,7 @@ protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String @Override protected List getSupportedPropertyDescriptors() { - return Collections.singletonList(SERVICE_TO_USE); + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/schema/inference/VolatileSchemaCache.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/schema/inference/VolatileSchemaCache.java index e2db7b74a35b..7daf4146a8c4 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/schema/inference/VolatileSchemaCache.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/schema/inference/VolatileSchemaCache.java @@ -38,7 +38,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; -import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -60,11 +59,15 @@ public class VolatileSchemaCache extends AbstractControllerService implements Re private static final Base64.Encoder ENCODER = Base64.getEncoder().withoutPadding(); + private static final List PROPERTIES = List.of( + MAX_SIZE + ); + private volatile Cache cache; @Override protected List getSupportedPropertyDescriptors() { - return Collections.singletonList(MAX_SIZE); + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/text/FreeFormTextRecordSetWriter.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/text/FreeFormTextRecordSetWriter.java index f91eb0cee1c1..027ae5ee6355 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/text/FreeFormTextRecordSetWriter.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/main/java/org/apache/nifi/text/FreeFormTextRecordSetWriter.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.charset.Charset; -import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -61,15 +60,17 @@ public class FreeFormTextRecordSetWriter extends AbstractControllerService imple .required(true) .build(); + private static final List PROPERTIES = List.of( + TEXT, + CHARACTER_SET + ); + private volatile PropertyValue textValue; private volatile Charset characterSet; @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(TEXT); - properties.add(CHARACTER_SET); - return properties; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java index 45e07ef418a2..cc3278a9caab 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/EmailRecordSink.java @@ -47,9 +47,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -176,6 +174,23 @@ public class EmailRecordSink extends AbstractControllerService implements Record .defaultValue("NiFi") .build(); + private static final List PROPERTIES = List.of( + FROM, + TO, + CC, + BCC, + SUBJECT, + SMTP_HOSTNAME, + SMTP_PORT, + SMTP_AUTH, + SMTP_USERNAME, + SMTP_PASSWORD, + SMTP_STARTTLS, + SMTP_SSL, + HEADER_XMAILER, + RecordSinkService.RECORD_WRITER_FACTORY + ); + private volatile RecordSetWriterFactory writerFactory; /** @@ -197,22 +212,7 @@ public class EmailRecordSink extends AbstractControllerService implements Record @Override protected List getSupportedPropertyDescriptors() { - return Collections.unmodifiableList(Arrays.asList( - FROM, - TO, - CC, - BCC, - SUBJECT, - SMTP_HOSTNAME, - SMTP_PORT, - SMTP_AUTH, - SMTP_USERNAME, - SMTP_PASSWORD, - SMTP_STARTTLS, - SMTP_SSL, - HEADER_XMAILER, - RecordSinkService.RECORD_WRITER_FACTORY - )); + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/HttpRecordSink.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/HttpRecordSink.java index 9c64655aecf1..4c2c2ec85916 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/HttpRecordSink.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/HttpRecordSink.java @@ -46,8 +46,6 @@ import java.io.InputStream; import java.net.URI; import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; @@ -94,6 +92,14 @@ public class HttpRecordSink extends AbstractControllerService implements RecordS .required(false) .build(); + private static final List PROPERTIES = List.of( + API_URL, + MAX_BATCH_SIZE, + RECORD_WRITER_FACTORY, + WEB_SERVICE_CLIENT_PROVIDER, + OAUTH2_ACCESS_TOKEN_PROVIDER + ); + private String apiUrl; private int maxBatchSize; private volatile RecordSetWriterFactory writerFactory; @@ -101,14 +107,6 @@ public class HttpRecordSink extends AbstractControllerService implements RecordS private volatile Optional oauth2AccessTokenProviderOptional; Map dynamicHttpHeaders; - public static final List PROPERTIES = Collections.unmodifiableList(Arrays.asList( - API_URL, - MAX_BATCH_SIZE, - RECORD_WRITER_FACTORY, - WEB_SERVICE_CLIENT_PROVIDER, - OAUTH2_ACCESS_TOKEN_PROVIDER - )); - @Override public List getSupportedPropertyDescriptors() { return PROPERTIES; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/LoggingRecordSink.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/LoggingRecordSink.java index 379bbab68e61..ab123fbb6eda 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/LoggingRecordSink.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/LoggingRecordSink.java @@ -22,7 +22,6 @@ import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.controller.ConfigurationContext; -import org.apache.nifi.controller.ControllerServiceInitializationContext; import org.apache.nifi.logging.ComponentLog; import org.apache.nifi.logging.LogLevel; import org.apache.nifi.reporting.InitializationException; @@ -35,8 +34,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -44,10 +41,6 @@ @CapabilityDescription("Provides a RecordSinkService that can be used to log records to the application log (nifi-app.log, e.g.) using the specified writer for formatting.") public class LoggingRecordSink extends AbstractControllerService implements RecordSinkService { - private List properties; - private volatile RecordSetWriterFactory writerFactory; - private volatile LogLevel logLevel; - public static final PropertyDescriptor LOG_LEVEL = new PropertyDescriptor.Builder() .name("logsink-log-level") .displayName("Log Level") @@ -57,18 +50,17 @@ public class LoggingRecordSink extends AbstractControllerService implements Reco .defaultValue(LogLevel.INFO.name()) .build(); - @Override - protected void init(final ControllerServiceInitializationContext context) throws InitializationException { - final List properties = new ArrayList<>(); - properties.add(RecordSinkService.RECORD_WRITER_FACTORY); - properties.add(LOG_LEVEL); + private static final List PROPERTIES = List.of( + RecordSinkService.RECORD_WRITER_FACTORY, + LOG_LEVEL + ); - this.properties = Collections.unmodifiableList(properties); - } + private volatile RecordSetWriterFactory writerFactory; + private volatile LogLevel logLevel; @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/event/UDPEventRecordSink.java b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/event/UDPEventRecordSink.java index 0151364e7476..f5e8b916e717 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/event/UDPEventRecordSink.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-record-sink-service-bundle/nifi-record-sink-service/src/main/java/org/apache/nifi/record/sink/event/UDPEventRecordSink.java @@ -39,8 +39,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.time.Duration; -import java.util.Arrays; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -80,13 +78,11 @@ public class UDPEventRecordSink extends AbstractControllerService implements Rec .defaultValue("2") .build(); - private static final List PROPERTY_DESCRIPTORS = Collections.unmodifiableList( - Arrays.asList( - HOSTNAME, - PORT, - RECORD_WRITER_FACTORY, - SENDER_THREADS - ) + private static final List PROPERTIES = List.of( + HOSTNAME, + PORT, + RECORD_WRITER_FACTORY, + SENDER_THREADS ); private static final String TRANSIT_URI_ATTRIBUTE_KEY = "record.sink.url"; @@ -101,7 +97,7 @@ public class UDPEventRecordSink extends AbstractControllerService implements Rec @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } @OnEnabled diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/PEMEncodedSSLContextProvider.java b/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/PEMEncodedSSLContextProvider.java index 16fe1cdd5992..ac9b017285dd 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/PEMEncodedSSLContextProvider.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/PEMEncodedSSLContextProvider.java @@ -141,7 +141,7 @@ public class PEMEncodedSSLContextProvider extends AbstractControllerService impl .dependsOn(CERTIFICATE_AUTHORITIES_SOURCE, CertificateAuthoritiesSource.PROPERTIES) .build(); - private static final List PROPERTY_DESCRIPTORS = List.of( + private static final List PROPERTIES = List.of( TLS_PROTOCOL, PRIVATE_KEY_SOURCE, PRIVATE_KEY, @@ -162,7 +162,7 @@ public class PEMEncodedSSLContextProvider extends AbstractControllerService impl @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java b/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java index 071fde7b887d..41d3e0e4c180 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-ssl-context-bundle/nifi-ssl-context-service/src/main/java/org/apache/nifi/ssl/StandardSSLContextService.java @@ -141,7 +141,7 @@ public class StandardSSLContextService extends AbstractControllerService impleme .sensitive(false) .build(); - private static final List properties = List.of( + private static final List PROPERTIES = List.of( KEYSTORE, KEYSTORE_PASSWORD, KEY_PASSWORD, @@ -185,7 +185,7 @@ public void onPropertyModified(PropertyDescriptor descriptor, String oldValue, S @Override protected List getSupportedPropertyDescriptors() { - return properties; + return PROPERTIES; } @Override diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-web-client-provider-bundle/nifi-web-client-provider-service/src/main/java/org/apache/nifi/web/client/provider/service/StandardWebClientServiceProvider.java b/nifi-extension-bundles/nifi-standard-services/nifi-web-client-provider-bundle/nifi-web-client-provider-service/src/main/java/org/apache/nifi/web/client/provider/service/StandardWebClientServiceProvider.java index c985e46a35cd..a2574f558150 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-web-client-provider-bundle/nifi-web-client-provider-service/src/main/java/org/apache/nifi/web/client/provider/service/StandardWebClientServiceProvider.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-web-client-provider-bundle/nifi-web-client-provider-service/src/main/java/org/apache/nifi/web/client/provider/service/StandardWebClientServiceProvider.java @@ -43,7 +43,6 @@ import javax.net.ssl.X509TrustManager; import java.net.Proxy; import java.time.Duration; -import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; @@ -99,7 +98,7 @@ public class StandardWebClientServiceProvider extends AbstractControllerService .identifiesControllerService(SSLContextProvider.class) .build(); - static final List PROPERTY_DESCRIPTORS = Arrays.asList( + private static final List PROPERTIES = List.of( CONNECT_TIMEOUT, READ_TIMEOUT, WRITE_TIMEOUT, @@ -162,7 +161,7 @@ public WebClientService getWebClientService() { @Override protected List getSupportedPropertyDescriptors() { - return PROPERTY_DESCRIPTORS; + return PROPERTIES; } private Duration getDuration(final ConfigurationContext context, final PropertyDescriptor propertyDescriptor) { diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceA.java b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceA.java index 184c32d70331..8a48bf1b8b6c 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceA.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceA.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.controller.service.mock; -import java.util.ArrayList; import java.util.List; import org.apache.nifi.components.PropertyDescriptor; @@ -39,10 +38,10 @@ public class ServiceA extends AbstractControllerService { @Override protected List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(OTHER_SERVICE); - descriptors.add(OTHER_SERVICE_2); - return descriptors; + return List.of( + OTHER_SERVICE, + OTHER_SERVICE_2 + ); } } diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceC.java b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceC.java index 8c46bb6da14a..bdbc5c43c42b 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceC.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceC.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.controller.service.mock; -import java.util.ArrayList; import java.util.List; import org.apache.nifi.components.PropertyDescriptor; @@ -45,11 +44,11 @@ public class ServiceC extends AbstractControllerService { @Override protected List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(REQ_SERVICE_1); - descriptors.add(REQ_SERVICE_2); - descriptors.add(OPT_SERVICE); - return descriptors; + return List.of( + REQ_SERVICE_1, + REQ_SERVICE_2, + OPT_SERVICE + ); } } diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceD.java b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceD.java index b61beadd4908..9f1fdf9a2a34 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceD.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/mock/ServiceD.java @@ -19,7 +19,6 @@ import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.controller.AbstractControllerService; -import java.util.ArrayList; import java.util.List; public class ServiceD extends AbstractControllerService { @@ -36,10 +35,10 @@ public class ServiceD extends AbstractControllerService { @Override protected List getSupportedPropertyDescriptors() { - final List descriptors = new ArrayList<>(); - descriptors.add(PROP_FOO1); - descriptors.add(PROP_FOO2); - return descriptors; + return List.of( + PROP_FOO1, + PROP_FOO2 + ); } } diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/ClassloaderIsolationKeyProviderService.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/ClassloaderIsolationKeyProviderService.java index 500fb5d586eb..89df1c5d8f83 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/ClassloaderIsolationKeyProviderService.java +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/ClassloaderIsolationKeyProviderService.java @@ -22,7 +22,6 @@ import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.processor.util.StandardValidators; -import java.util.Collections; import java.util.List; public class ClassloaderIsolationKeyProviderService extends AbstractControllerService implements KeyProviderService { @@ -36,7 +35,9 @@ public class ClassloaderIsolationKeyProviderService extends AbstractControllerSe private volatile String keyField; - private static final List PROPERTIES = Collections.singletonList(KEY_FIELD); + private static final List PROPERTIES = List.of( + KEY_FIELD + ); @Override protected List getSupportedPropertyDescriptors() { diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/EnsureControllerServiceConfigurationCorrect.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/EnsureControllerServiceConfigurationCorrect.java index 65b7b365cc7e..bb1c2339796b 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/EnsureControllerServiceConfigurationCorrect.java +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/EnsureControllerServiceConfigurationCorrect.java @@ -26,7 +26,6 @@ import org.apache.nifi.logging.ComponentLog; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; @@ -72,7 +71,12 @@ public class EnsureControllerServiceConfigurationCorrect extends AbstractControl @Override protected List getSupportedPropertyDescriptors() { - return Arrays.asList(SUCCESSFUL_VERIFICATION, VERIFICATION_STEPS, EXCEPTION_ON_VERIFICATION, FAILURE_NODE_NUMBER); + return List.of( + SUCCESSFUL_VERIFICATION, + VERIFICATION_STEPS, + EXCEPTION_ON_VERIFICATION, + FAILURE_NODE_NUMBER + ); } @Override diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/LifecycleFailureService.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/LifecycleFailureService.java index 59df1c404fa9..f22df2058120 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/LifecycleFailureService.java +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/LifecycleFailureService.java @@ -24,7 +24,6 @@ import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.processor.util.StandardValidators; -import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; @@ -50,7 +49,10 @@ public class LifecycleFailureService extends AbstractControllerService { @Override protected List getSupportedPropertyDescriptors() { - return Arrays.asList(ENABLE_FAILURE_COUNT, FAIL_ON_DISABLE); + return List.of( + ENABLE_FAILURE_COUNT, + FAIL_ON_DISABLE + ); } @OnEnabled diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardCountService.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardCountService.java index b66bbd4213ca..3bfd001ad903 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardCountService.java +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardCountService.java @@ -23,7 +23,6 @@ import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.processor.util.StandardValidators; -import java.util.Arrays; import java.util.List; import java.util.concurrent.atomic.AtomicLong; @@ -48,7 +47,10 @@ public class StandardCountService extends AbstractControllerService implements C @Override protected List getSupportedPropertyDescriptors() { - return Arrays.asList(COUNT_SERVICE, START_VALUE); + return List.of( + COUNT_SERVICE, + START_VALUE + ); } @OnEnabled diff --git a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardSleepService.java b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardSleepService.java index 03d7d38d0c6c..7605a3c43390 100644 --- a/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardSleepService.java +++ b/nifi-system-tests/nifi-system-test-extensions-bundle/nifi-system-test-extensions-services/src/main/java/org/apache/nifi/cs/tests/system/StandardSleepService.java @@ -25,7 +25,6 @@ import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.processor.util.StandardValidators; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -69,13 +68,13 @@ public class StandardSleepService extends AbstractControllerService implements S @Override protected List getSupportedPropertyDescriptors() { - final List properties = new ArrayList<>(); - properties.add(VALIDATE_SLEEP_TIME); - properties.add(ON_ENABLED_SLEEP_TIME); - properties.add(TRIGGER_SLEEP_TIME); - properties.add(ON_DISABLED_SLEEP_TIME); - properties.add(DEPENDENT_SERVICE); - return properties; + return List.of( + VALIDATE_SLEEP_TIME, + ON_ENABLED_SLEEP_TIME, + TRIGGER_SLEEP_TIME, + ON_DISABLED_SLEEP_TIME, + DEPENDENT_SERVICE + ); } @Override