This is an automated email from the ASF dual-hosted git repository.
pvillard31 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 1288f20dd30 NIFI-16597 Replaced Non-constant string concatenation
argument in logging call with parameterized logging placeholders. (#11935)
1288f20dd30 is described below
commit 1288f20dd308eed5bfe516ecd9f2c4b29d21f307
Author: dan-s1 <[email protected]>
AuthorDate: Thu Nov 19 05:04:07 2026 -0500
NIFI-16597 Replaced Non-constant string concatenation argument in logging
call with parameterized logging placeholders. (#11935)
---
.../apache/nifi/c2/client/service/C2OperationManager.java | 2 +-
.../bootstrap/command/io/FileResponseStreamHandler.java | 2 +-
.../java/org/apache/nifi/security/krb/KerberosUserIT.java | 2 +-
.../java/org/apache/nifi/processors/hadoop/ListHDFS.java | 4 ++--
.../java/org/apache/nifi/provenance/lucene/DocsReader.java | 3 +--
.../cluster/coordination/node/NodeClusterCoordinator.java | 3 +--
.../org/apache/nifi/controller/StandardProcessorNode.java | 13 +++++++------
.../nifi/components/monitor/LongRunningTaskMonitor.java | 4 ++--
.../org/apache/nifi/controller/StandardFlowService.java | 5 +++--
.../apache/nifi/components/LongRunningTaskMonitorTest.java | 9 ---------
.../nifi/registry/provider/flow/git/GitFlowMetaData.java | 2 +-
.../provider/flow/git/GitFlowPersistenceProvider.java | 4 ++--
12 files changed, 22 insertions(+), 31 deletions(-)
diff --git
a/c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2OperationManager.java
b/c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2OperationManager.java
index 2925a4c78df..22066b79c21 100644
---
a/c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2OperationManager.java
+++
b/c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2OperationManager.java
@@ -99,7 +99,7 @@ public class C2OperationManager implements Runnable {
try {
operationAck = operationHandler.handle(operation);
} catch (Exception e) {
- LOGGER.error("Failed to process operation " + operation, e);
+ LOGGER.error("Failed to process operation {}", operation, e);
continue;
}
diff --git
a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/command/io/FileResponseStreamHandler.java
b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/command/io/FileResponseStreamHandler.java
index d4127641d72..1aba0392a03 100644
---
a/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/command/io/FileResponseStreamHandler.java
+++
b/nifi-bootstrap/src/main/java/org/apache/nifi/bootstrap/command/io/FileResponseStreamHandler.java
@@ -43,7 +43,7 @@ public class FileResponseStreamHandler implements
ResponseStreamHandler {
try (OutputStream outputStream = Files.newOutputStream(outputPath)) {
responseStream.transferTo(outputStream);
} catch (final IOException e) {
- logger.warn("Write response stream failed for
[%s]".formatted(outputPath), e);
+ logger.warn("Write response stream failed for {}", outputPath, e);
}
}
}
diff --git
a/nifi-commons/nifi-security-kerberos/src/test/java/org/apache/nifi/security/krb/KerberosUserIT.java
b/nifi-commons/nifi-security-kerberos/src/test/java/org/apache/nifi/security/krb/KerberosUserIT.java
index d16403fd209..32ce33ef66d 100644
---
a/nifi-commons/nifi-security-kerberos/src/test/java/org/apache/nifi/security/krb/KerberosUserIT.java
+++
b/nifi-commons/nifi-security-kerberos/src/test/java/org/apache/nifi/security/krb/KerberosUserIT.java
@@ -178,7 +178,7 @@ public class KerberosUserIT {
long currentTimeMillis = System.currentTimeMillis();
long startMilli =
kerberosTicket.getStartTime().toInstant().toEpochMilli();
long endMilli = kerberosTicket.getEndTime().toInstant().toEpochMilli();
- logger.info("New ticket is valid for {}",
TimeUnit.MILLISECONDS.toSeconds(endMilli - startMilli) + " seconds");
+ logger.info("New ticket is valid for {} seconds",
TimeUnit.MILLISECONDS.toSeconds(endMilli - startMilli));
assertTrue(startMilli < currentTimeMillis);
assertTrue(endMilli > currentTimeMillis);
}
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 73877dc567c..9a604d1e05e 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
@@ -245,8 +245,8 @@ public class ListHDFS extends AbstractHadoopProcessor {
final long legacyLatestEmittedTimestamp =
Long.parseLong(legacyLatestEmittedTimestampString);
latestTimestamp = legacyLatestListingTimestamp ==
legacyLatestEmittedTimestamp ? legacyLatestListingTimestamp + 1 :
legacyLatestListingTimestamp;
latestFiles = new ArrayList<>();
- getLogger().debug("Transitioned from legacy state to new
state. 'legacyLatestListingTimestamp': {}, 'legacyLatestEmittedTimeStamp':
{}'," +
- "'latestTimestamp': {}", legacyLatestListingTimestamp,
legacyLatestEmittedTimestamp, latestTimestamp);
+ getLogger().debug("Transitioned from legacy state to new
state. 'legacyLatestListingTimestamp': {}, 'legacyLatestEmittedTimeStamp': {},
'latestTimestamp': {}",
+ legacyLatestListingTimestamp,
legacyLatestEmittedTimestamp, latestTimestamp);
} else if (latestTimestampString != null) {
latestTimestamp = Long.parseLong(latestTimestampString);
latestFiles = stateMap.toMap().entrySet().stream()
diff --git
a/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/lucene/DocsReader.java
b/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/lucene/DocsReader.java
index 5937a239f4d..2c93dc864cb 100644
---
a/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/lucene/DocsReader.java
+++
b/nifi-framework-bundle/nifi-framework-extensions/nifi-provenance-repository-bundle/nifi-persistent-provenance-repository/src/main/java/org/apache/nifi/provenance/lucene/DocsReader.java
@@ -139,8 +139,7 @@ public class DocsReader {
}
}
} catch (final Exception e) {
- logger.warn("Failed to read Provenance Events. The event file
'"
- + provenanceEventFile.getAbsolutePath() + "' may be
missing or corrupt.", e);
+ logger.warn("Failed to read Provenance Events. The event file
'{}' may be missing or corrupt.", provenanceEventFile.getAbsolutePath(), e);
}
}
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
index 666712b196a..78aa701ef93 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/node/NodeClusterCoordinator.java
@@ -1336,8 +1336,7 @@ public class NodeClusterCoordinator implements
ClusterCoordinator, ProtocolHandl
try {
dataFlow = flowService.createDataFlowFromController();
} catch (final IOException ioe) {
- logger.error("Unable to obtain current dataflow from
FlowService in order to provide the flow to "
- + resolvedNodeIdentifier + ". Will tell node to try again
later", ioe);
+ logger.error("Unable to obtain current dataflow from
FlowService in order to provide the flow to {}. Will tell node to try again
later", resolvedNodeIdentifier, ioe);
}
}
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
index ca158e0b10e..5d7edd657ea 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/StandardProcessorNode.java
@@ -148,6 +148,12 @@ import java.util.stream.Stream;
public class StandardProcessorNode extends ProcessorNode implements
Connectable {
private static final Logger LOG =
LoggerFactory.getLogger(StandardProcessorNode.class);
+ private static final String TIMEOUT_MSG = "Timed out while waiting for
OnScheduled of {} "
+ + "to finish. An attempt is made to cancel the task via
Thread.interrupt(). However it does not "
+ + "guarantee that the task will be canceled since the code inside
current OnScheduled operation may "
+ + "have been written to ignore interrupts which may result in a
runaway thread. This could lead to more issues, "
+ + "eventually requiring NiFi to be restarted. This is usually a
bug in the target Processor '{}' "
+ + "that needs to be documented, reported and eventually fixed.";
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setDefaultPropertyInclusion(JsonInclude.Include.NON_NULL);
@@ -2305,12 +2311,7 @@ public class StandardProcessorNode extends ProcessorNode
implements Connectable
monitoringFuture.cancel(false);
final Processor processor = processorRef.get().getProcessor();
- LOG.warn("Timed out while waiting for OnScheduled of "
- + processor + " to finish. An attempt is made to cancel the
task via Thread.interrupt(). However it does not "
- + "guarantee that the task will be canceled since the code
inside current OnScheduled operation may "
- + "have been written to ignore interrupts which may result in
a runaway thread. This could lead to more issues, "
- + "eventually requiring NiFi to be restarted. This is usually
a bug in the target Processor '"
- + processor + "' that needs to be documented, reported and
eventually fixed.");
+ LOG.warn(TIMEOUT_MSG, processor, processor);
}
}
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/monitor/LongRunningTaskMonitor.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/monitor/LongRunningTaskMonitor.java
index a13b5440b7f..7413e7311d6 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/monitor/LongRunningTaskMonitor.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/components/monitor/LongRunningTaskMonitor.java
@@ -62,8 +62,8 @@ public class LongRunningTaskMonitor implements Runnable {
String taskSeconds = String.format("%,d seconds",
activeThread.getActiveMillis() / 1000);
- getLogger().warn(String.format("Long running task detected
on processor [id=%s, name=%s, type=%s]. Task time: %s. Stack trace:\n%s",
- processorNode.getIdentifier(),
processorNode.getName(), processorNode.getComponentType(), taskSeconds,
activeThread.getStackTrace()));
+ getLogger().warn("Long running task detected on processor
[id={}, name={}, type={}]. Task time: {}. Stack trace:\n{}",
+ processorNode.getIdentifier(),
processorNode.getName(), processorNode.getComponentType(), taskSeconds,
activeThread.getStackTrace());
eventReporter.reportEvent(Severity.WARNING, "Long Running
Task", String.format("Processor with ID %s, Name %s and Type %s has a task that
has been running for %s " +
"(thread name: %s).",
processorNode.getIdentifier(), processorNode.getName(),
processorNode.getComponentType(), taskSeconds, activeThread.getThreadName()));
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
index 25da34effb9..7f725b82767 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/StandardFlowService.java
@@ -108,6 +108,8 @@ public class StandardFlowService implements FlowService,
ProtocolHandler {
private static final String EVENT_CATEGORY = "Controller";
private static final String CLUSTER_NODE_CONFIG = "Cluster Node
Configuration";
+ private static final String RETRY_MSG = "Received a 'try again' response
from Cluster Coordinator when attempting to connect to cluster with explanation
'{}'. "
+ + "However, the maximum number of retries have already completed.
Will load local flow and connect to the cluster when able.";
// state keys
private static final String NODE_UUID = "Node UUID";
@@ -973,8 +975,7 @@ public class StandardFlowService implements FlowService,
ProtocolHandler {
// if response indicates we should try later, then coordinator
was unable to service our request. Just load local flow and move on.
// when the cluster coordinator is able to service requests,
this node's heartbeat will trigger the cluster coordinator to reach
// out to this node and re-connect to the cluster.
- logger.info("Received a 'try again' response from Cluster
Coordinator when attempting to connect to cluster with explanation '"
- + response.getRejectionReason() + "'. However, the maximum
number of retries have already completed. Will load local flow and connect to
the cluster when able.");
+ logger.info(RETRY_MSG, response.getRejectionReason());
return null;
} else {
// cluster manager provided a successful response with a
current dataflow
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
index 8ba978910f7..ea4a7dec173 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/components/LongRunningTaskMonitorTest.java
@@ -29,11 +29,8 @@ import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;
-import java.text.NumberFormat;
import java.util.Arrays;
-import java.util.Locale;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -85,12 +82,6 @@ public class LongRunningTaskMonitorTest {
longRunningTaskMonitor.run();
- ArgumentCaptor<String> logMessages =
ArgumentCaptor.forClass(String.class);
- verify(longRunningTaskMonitorLogger,
times(2)).warn(logMessages.capture());
- assertEquals("Long running task detected on processor
[id=Processor-1-ID, name=Processor-1-Name, type=Processor-1-Type]. Task time:
60 seconds. Stack trace:\n" + STACKTRACE,
- logMessages.getAllValues().get(0));
- assertEquals("Long running task detected on processor
[id=Processor-2-ID, name=Processor-2-Name, type=Processor-2-Type]. Task time:
1,000 seconds. Stack trace:\n" + STACKTRACE,
-
logMessages.getAllValues().get(1).replace(NumberFormat.getInstance(Locale.getDefault()).format(1000),
NumberFormat.getInstance(Locale.US).format(1000)));
ArgumentCaptor<String> controllerBulletinMessages =
ArgumentCaptor.forClass(String.class);
verify(eventReporter, times(2)).reportEvent(eq(Severity.WARNING),
eq("Long Running Task"), controllerBulletinMessages.capture());
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowMetaData.java
b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowMetaData.java
index 9b6c221528e..a95f3fbd77e 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowMetaData.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowMetaData.java
@@ -301,7 +301,7 @@ class GitFlowMetaData {
logger.debug(pushResult.getMessages());
}
} catch (GitAPIException e) {
- logger.error(format("Failed to push commits to %s due to %s",
remoteToPush, e), e);
+ logger.error("Failed to push commits to {}", remoteToPush, e);
}
}, 10, 10, TimeUnit.SECONDS);
diff --git
a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java
b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java
index 075102c0960..36b762ec2dd 100644
---
a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java
+++
b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/provider/flow/git/GitFlowPersistenceProvider.java
@@ -217,8 +217,8 @@ public class GitFlowPersistenceProvider implements
MetadataAwareFlowPersistenceP
final Bucket bucket = getBucketOrFail(bucketId);
final Optional<Flow> flowOpt = bucket.getFlow(flowId);
if (!flowOpt.isPresent()) {
- logger.debug(format("Tried deleting all versions, but the Flow ID
%s was not found in bucket %s:%s.",
- flowId, bucket.getBucketDirName(), bucket.getBucketId()));
+ logger.debug("Tried deleting all versions, but the Flow ID {} was
not found in bucket {}:{}.",
+ flowId, bucket.getBucketDirName(), bucket.getBucketId());
return;
}