You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2026/07/07 18:25:00 UTC
[jira] [Commented] (NIFI-16073) Apply Pattern variable in other places in the code base and make preexisting pattern variables final
[ https://issues.apache.org/jira/browse/NIFI-16073?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18094365#comment-18094365 ]
ASF subversion and git services commented on NIFI-16073:
--------------------------------------------------------
Commit d7b581916d916b69df750c0bb746bc205337c9a3 in nifi's branch refs/heads/main from dan-s1
[ https://gitbox.apache.org/repos/asf?p=nifi.git;h=d7b581916d9 ]
NIFI-16073 Applied Pattern variable in other places in the code base and made preexisting pattern variables final (#11392)
> Apply Pattern variable in other places in the code base and make preexisting pattern variables final
> ----------------------------------------------------------------------------------------------------
>
> Key: NIFI-16073
> URL: https://issues.apache.org/jira/browse/NIFI-16073
> Project: Apache NiFi
> Issue Type: Improvement
> Reporter: Daniel Stieglitz
> Assignee: Daniel Stieglitz
> Priority: Minor
> Time Spent: 40m
> Remaining Estimate: 0h
>
> This ticket picks up where tickets NIFI-16041 and NIFI-16052 left off in that it aims to implement the pattern variable in other places of the code and make preexisting ones final.
> In many cases, the use of the pattern variable cleans up a lot of duplicate casts for example in nifi-extension-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/processors/hadoop/util/OutputStreamWritable .java the following snippet is before the pattern variable:
> {code:java}
> if (in instanceof DataInputBuffer) {
> byte[] bytes = ((DataInputBuffer) in).getData();
> int pos = ((DataInputBuffer) in).getPosition();
> int length = ((DataInputBuffer) in).getLength();
> int bytesRemaining = length - pos;{code}
> and after the use of the pattern variable
> {code:java}
> if (in instanceof final DataInputBuffer dataInputBuffer) {
> byte[] bytes = dataInputBuffer.getData();
> int pos = dataInputBuffer.getPosition();
> int length = dataInputBuffer.getLength();{code}
>
> Another example is
> nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/RepositoryContextFactory.java
> Before
> {code:java}
> public RepositoryContext newProcessContext(final Connectable connectable, final AtomicLong connectionIndex) {
> final Class<?> componentClass = (connectable instanceof ProcessorNode && ((ProcessorNode) connectable).getProcessor() != null)
> ? ((ProcessorNode) connectable).getProcessor().getClass()
> : null;{code}
> After
> {code:java}
> public RepositoryContext newProcessContext(final Connectable connectable, final AtomicLong connectionIndex) {
> final Class<?> componentClass = (connectable instanceof final ProcessorNode processorNode && processorNode.getProcessor() != null)
> ? processorNode.getProcessor().getClass()
> : null;{code}
>
> Another example
> nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQuery.java
> Before
> {code:java}
> else if (obj instanceof Object[] && ((Object[]) obj).length > 0 && ((Object[]) obj)[0] instanceof MapRecord) {
> List<Map<String, Object>> list = new ArrayList<>();
> for (Object item : (Object[]) obj) {
> list.add(convertMapRecord(((MapRecord) item).toMap(), fieldSchema.getFieldsList()));
> }
> result.put(key, list);
> continue;
> }{code}
> After
> {code:java}
> else if (obj instanceof final Object[] objects && objects.length > 0 && objects[0] instanceof MapRecord) {
> List<Map<String, Object>> list = new ArrayList<>();
> for (Object item : objects) {
> list.add(convertMapRecord(((MapRecord) item).toMap(), fieldSchema.getFieldsList()));
> }
> result.put(key, list);
> continue;
> }{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)