This is an automated email from the ASF dual-hosted git repository. voonhous pushed a commit to branch release-1.2.1 in repository https://gitbox.apache.org/repos/asf/hudi.git
commit f0590792592034739487c7c189b6be72edbe2a97 Author: voonhous <[email protected]> AuthorDate: Sat Jul 4 17:44:47 2026 +0800 refactor(common): use SLF4J parameterized logging instead of string concatenation (#19158) Convert log string concatenation to {} placeholders across hudi-common. Mechanical and behavior-preserving. Notable manual handling: - ZookeeperTestService: pass e.toString() (not e) so the exception stays an inline message value instead of being peeled as the SLF4J stacktrace arg, preserving the existing 'ignore as expected' behavior. - ConfigUtils: drop redundant path.toString() in the parameterized arg. - JmxMetricsReporter: the message wraps the value in literal braces; written as "{port: {}}" so SLF4J fills the inner {} and keeps the outer braces. (cherry picked from commit 1030cf9d1af7192e2328fe0cf0ce4041abc024bf) --- .../apache/hudi/common/model/HoodieCommitMetadata.java | 2 +- .../hudi/common/table/timeline/TimelineUtils.java | 2 +- .../common/table/view/RocksDbBasedFileSystemView.java | 10 ++++------ .../java/org/apache/hudi/common/util/ConfigUtils.java | 2 +- .../org/apache/hudi/metrics/JmxMetricsReporter.java | 8 ++++---- .../apache/hudi/metrics/MetricsReporterFactory.java | 2 +- .../org/apache/hudi/TestReportJvmConfiguration.java | 18 +++++++++--------- .../testutils/minicluster/ZookeeperTestService.java | 6 +++--- 8 files changed, 24 insertions(+), 26 deletions(-) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieCommitMetadata.java b/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieCommitMetadata.java index 51171b83b0e6..949f766e13cc 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieCommitMetadata.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/model/HoodieCommitMetadata.java @@ -220,7 +220,7 @@ public class HoodieCommitMetadata implements Serializable { public String toJsonString() throws IOException { if (partitionToWriteStats.containsKey(null)) { - log.info("partition path is null for " + partitionToWriteStats.get(null)); + log.info("partition path is null for {}", partitionToWriteStats.get(null)); partitionToWriteStats.remove(null); } return JsonUtils.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(this); diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineUtils.java b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineUtils.java index 6c27d1f8e2a6..647cab77123d 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineUtils.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/table/timeline/TimelineUtils.java @@ -263,7 +263,7 @@ public class TimelineUtils { private static Option<String> getMetadataValue(HoodieTableMetaClient metaClient, String extraMetadataKey, HoodieInstant instant) { try { - log.info("reading checkpoint info for:" + instant + " key: " + extraMetadataKey); + log.info("reading checkpoint info for:{} key: {}", instant, extraMetadataKey); byte[] contents = metaClient.getCommitsTimeline().getInstantDetails(instant).get(); if (instant.isCompleted()) { if (contents == null || contents.length == 0) { diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java b/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java index fee37f33380b..c8df4063abf0 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java @@ -207,8 +207,7 @@ public class RocksDbBasedFileSystemView extends IncrementalTimelineSyncFileSyste @Override void resetFileGroupsInPendingClustering(Map<HoodieFileGroupId, HoodieInstant> fgIdToInstantMap) { - log.info("Resetting file groups in pending clustering to ROCKSDB based file-system view at " - + config.getRocksdbBasePath() + ", Total file-groups=" + fgIdToInstantMap.size()); + log.info("Resetting file groups in pending clustering to ROCKSDB based file-system view at {}, Total file-groups={}", config.getRocksdbBasePath(), fgIdToInstantMap.size()); // Delete all replaced file groups rocksDB.prefixDelete(schemaHelper.getColFamilyForFileGroupsInPendingClustering(), "part="); @@ -517,8 +516,7 @@ public class RocksDbBasedFileSystemView extends IncrementalTimelineSyncFileSyste @Override protected void resetReplacedFileGroups(final Map<HoodieFileGroupId, HoodieInstant> replacedFileGroups) { - log.info("Resetting replacedFileGroups to ROCKSDB based file-system view at " - + config.getRocksdbBasePath() + ", Total file-groups=" + replacedFileGroups.size()); + log.info("Resetting replacedFileGroups to ROCKSDB based file-system view at {}, Total file-groups={}", config.getRocksdbBasePath(), replacedFileGroups.size()); // Delete all replaced file groups rocksDB.prefixDelete(schemaHelper.getColFamilyForReplacedFileGroups(), "part="); @@ -543,8 +541,8 @@ public class RocksDbBasedFileSystemView extends IncrementalTimelineSyncFileSyste }) ); - log.info("Finished adding replaced file groups to partition (" + partitionPath + ") to ROCKSDB based view at " - + config.getRocksdbBasePath() + ", Total file-groups=" + partitionToReplacedFileGroupsEntry.getValue().size()); + log.info("Finished adding replaced file groups to partition ({}) to ROCKSDB based view at {}, Total file-groups={}", + partitionPath, config.getRocksdbBasePath(), partitionToReplacedFileGroupsEntry.getValue().size()); }); } diff --git a/hudi-common/src/main/java/org/apache/hudi/common/util/ConfigUtils.java b/hudi-common/src/main/java/org/apache/hudi/common/util/ConfigUtils.java index 5f0ce3bbb9a0..6fb81390ccda 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/util/ConfigUtils.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/util/ConfigUtils.java @@ -682,7 +682,7 @@ public class ConfigUtils { return props; } catch (IOException e) { if (HoodieExceptionUtil.isPermissionDeniedException(e)) { - log.error("Permission denied for " + path.toString() + " file.", e); + log.error("Permission denied for {} file.", path, e); throw new HoodieIOException("Permission denied for " + path + " file path. User does not have read access on the dataset.", e); } else { log.warn("Could not read properties from {}: {}", path, e); diff --git a/hudi-common/src/main/java/org/apache/hudi/metrics/JmxMetricsReporter.java b/hudi-common/src/main/java/org/apache/hudi/metrics/JmxMetricsReporter.java index 623a055100a7..da3613165285 100644 --- a/hudi-common/src/main/java/org/apache/hudi/metrics/JmxMetricsReporter.java +++ b/hudi-common/src/main/java/org/apache/hudi/metrics/JmxMetricsReporter.java @@ -60,7 +60,7 @@ public class JmxMetricsReporter extends MetricsReporter { "Could not start JMX server on any configured port. Ports: " + portsConfig + ". Maybe require port range for multiple hoodie tables"); } - log.info("Configured JMXReporter with {port:" + portsConfig + "}"); + log.info("Configured JMXReporter with {port: {}}", portsConfig); } catch (Exception e) { String msg = "Jmx initialize failed: "; log.error(msg, e); @@ -76,13 +76,13 @@ public class JmxMetricsReporter extends MetricsReporter { for (int port : ports) { try { jmxReporterServer = createJmxReport(host, port); - log.info("Started JMX server on port " + port + "."); + log.info("Started JMX server on port {}.", port); break; } catch (Exception e) { if (e.getCause() instanceof ExportException) { - log.info("Skip for initializing jmx port " + port + " because of already in use"); + log.info("Skip for initializing jmx port {} because of already in use", port); } else { - log.info("Failed to initialize jmx port " + port + ". " + e.getMessage()); + log.info("Failed to initialize jmx port {}. {}", port, e.getMessage()); } } } diff --git a/hudi-common/src/main/java/org/apache/hudi/metrics/MetricsReporterFactory.java b/hudi-common/src/main/java/org/apache/hudi/metrics/MetricsReporterFactory.java index b93968e23d73..e2b850e8732f 100644 --- a/hudi-common/src/main/java/org/apache/hudi/metrics/MetricsReporterFactory.java +++ b/hudi-common/src/main/java/org/apache/hudi/metrics/MetricsReporterFactory.java @@ -94,7 +94,7 @@ public class MetricsReporterFactory { reporter = new Slf4jMetricsReporter(registry); break; default: - log.error("Reporter type[" + type + "] is not supported."); + log.error("Reporter type[{}] is not supported.", type); break; } return Option.ofNullable(reporter); diff --git a/hudi-common/src/test/java/org/apache/hudi/TestReportJvmConfiguration.java b/hudi-common/src/test/java/org/apache/hudi/TestReportJvmConfiguration.java index ea3eeade1baa..57edd95e1c65 100644 --- a/hudi-common/src/test/java/org/apache/hudi/TestReportJvmConfiguration.java +++ b/hudi-common/src/test/java/org/apache/hudi/TestReportJvmConfiguration.java @@ -42,14 +42,14 @@ public class TestReportJvmConfiguration { MemoryUsage nonHeapMemoryUsage = memoryBean.getNonHeapMemoryUsage(); LOG.warn("Heap Memory Usage (MemoryMXBean):"); - LOG.warn(" Used: " + heapMemoryUsage.getUsed() + " bytes"); - LOG.warn(" Committed: " + heapMemoryUsage.getCommitted() + " bytes"); - LOG.warn(" Max: " + heapMemoryUsage.getMax() + " bytes"); + LOG.warn(" Used: {} bytes", heapMemoryUsage.getUsed()); + LOG.warn(" Committed: {} bytes", heapMemoryUsage.getCommitted()); + LOG.warn(" Max: {} bytes", heapMemoryUsage.getMax()); LOG.warn("Non-Heap Memory Usage (MemoryMXBean):"); - LOG.warn(" Used: " + nonHeapMemoryUsage.getUsed() + " bytes"); - LOG.warn(" Committed: " + nonHeapMemoryUsage.getCommitted() + " bytes"); - LOG.warn(" Max: " + nonHeapMemoryUsage.getMax() + " bytes"); + LOG.warn(" Used: {} bytes", nonHeapMemoryUsage.getUsed()); + LOG.warn(" Committed: {} bytes", nonHeapMemoryUsage.getCommitted()); + LOG.warn(" Max: {} bytes", nonHeapMemoryUsage.getMax()); } private void reportMemoryUsageWithRuntime() { @@ -60,8 +60,8 @@ public class TestReportJvmConfiguration { long usedMemory = totalMemory - freeMemory; LOG.warn("Memory Usage (Runtime):"); - LOG.warn(" Total Memory: " + totalMemory + " bytes"); - LOG.warn(" Free Memory: " + freeMemory + " bytes"); - LOG.warn(" Used Memory: " + usedMemory + " bytes"); + LOG.warn(" Total Memory: {} bytes", totalMemory); + LOG.warn(" Free Memory: {} bytes", freeMemory); + LOG.warn(" Used Memory: {} bytes", usedMemory); } } diff --git a/hudi-common/src/test/java/org/apache/hudi/common/testutils/minicluster/ZookeeperTestService.java b/hudi-common/src/test/java/org/apache/hudi/common/testutils/minicluster/ZookeeperTestService.java index d3e835966242..779f4cb89ef7 100644 --- a/hudi-common/src/test/java/org/apache/hudi/common/testutils/minicluster/ZookeeperTestService.java +++ b/hudi-common/src/test/java/org/apache/hudi/common/testutils/minicluster/ZookeeperTestService.java @@ -101,7 +101,7 @@ public class ZookeeperTestService { // NOTE: Changed from the original, where InetSocketAddress was // originally created to bind to the wildcard IP, we now configure it. - log.info("Zookeeper force binding to: " + this.bindIP); + log.info("Zookeeper force binding to: {}", this.bindIP); standaloneServerFactory.configure(new InetSocketAddress(bindIP, clientPort), 1000); // Start up this ZK server @@ -118,7 +118,7 @@ public class ZookeeperTestService { } started = true; - log.info("Zookeeper Minicluster service started on client port: " + clientPort); + log.info("Zookeeper Minicluster service started on client port: {}", clientPort); return zooKeeperServer; } @@ -217,7 +217,7 @@ public class ZookeeperTestService { } } catch (IOException e) { // ignore as this is expected - log.info("server " + hostname + ":" + port + " not up " + e); + log.info("server {}:{} not up {}", hostname, port, e.toString()); } if (System.currentTimeMillis() > start + timeout) {
