This is an automated email from the ASF dual-hosted git repository.
chia7712 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 98e13b7ba8d MINOR: Move TerseFailure to server-common (#21890)
98e13b7ba8d is described below
commit 98e13b7ba8dc92c2306ce62910f08f43a7f3a2b3
Author: Ken Huang <[email protected]>
AuthorDate: Wed Apr 1 12:35:31 2026 +0800
MINOR: Move TerseFailure to server-common (#21890)
Rewite this class and move to server-common module
Reviewers: Chia-Ping Tsai <[email protected]>
---
.../scala/kafka/docker/KafkaDockerWrapper.scala | 3 ++-
core/src/main/scala/kafka/tools/StorageTool.scala | 1 +
.../scala/unit/kafka/tools/StorageToolTest.scala | 1 +
.../org/apache/kafka/server/util/TerseFailure.java | 29 ++++++++++++++--------
.../java/org/apache/kafka/shell/MetadataShell.java | 3 +--
5 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/core/src/main/scala/kafka/docker/KafkaDockerWrapper.scala
b/core/src/main/scala/kafka/docker/KafkaDockerWrapper.scala
index d81a0b34368..3faa3843ed8 100644
--- a/core/src/main/scala/kafka/docker/KafkaDockerWrapper.scala
+++ b/core/src/main/scala/kafka/docker/KafkaDockerWrapper.scala
@@ -22,13 +22,14 @@ import
com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory
import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature
import kafka.Kafka
-import kafka.tools.{StorageTool, TerseFailure}
+import kafka.tools.StorageTool
import kafka.utils.Logging
import net.sourceforge.argparse4j.ArgumentParsers
import net.sourceforge.argparse4j.impl.Arguments.store
import net.sourceforge.argparse4j.inf.Namespace
import org.apache.kafka.common.utils.Exit
import org.apache.kafka.raft.QuorumConfig
+import org.apache.kafka.server.util.TerseFailure
import java.nio.charset.StandardCharsets
import java.nio.file.{Files, Path, Paths, StandardCopyOption,
StandardOpenOption}
diff --git a/core/src/main/scala/kafka/tools/StorageTool.scala
b/core/src/main/scala/kafka/tools/StorageTool.scala
index dc696296fd4..56c03921f80 100644
--- a/core/src/main/scala/kafka/tools/StorageTool.scala
+++ b/core/src/main/scala/kafka/tools/StorageTool.scala
@@ -32,6 +32,7 @@ import org.apache.kafka.metadata.properties.{MetaProperties,
MetaPropertiesEnsem
import org.apache.kafka.metadata.storage.{Formatter, FormatterException}
import org.apache.kafka.raft.{DynamicVoters, QuorumConfig}
import org.apache.kafka.server.ProcessRole
+import org.apache.kafka.server.util.TerseFailure
import java.util
import scala.collection.mutable
diff --git a/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
b/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
index e2542204706..4ae84c03685 100644
--- a/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
+++ b/core/src/test/scala/unit/kafka/tools/StorageToolTest.scala
@@ -34,6 +34,7 @@ import org.apache.kafka.metadata.storage.FormatterException
import org.apache.kafka.network.SocketServerConfigs
import org.apache.kafka.raft.{KRaftConfigs, MetadataLogConfig, QuorumConfig}
import org.apache.kafka.server.config.{ServerConfigs, ServerLogConfigs}
+import org.apache.kafka.server.util.TerseFailure
import org.junit.jupiter.api.Assertions.{assertEquals, assertFalse,
assertThrows, assertTrue}
import org.junit.jupiter.api.{Test, Timeout}
import org.junit.jupiter.params.ParameterizedTest
diff --git a/core/src/main/scala/kafka/tools/TerseFailure.scala
b/server/src/main/java/org/apache/kafka/server/util/TerseFailure.java
similarity index 55%
rename from core/src/main/scala/kafka/tools/TerseFailure.scala
rename to server/src/main/java/org/apache/kafka/server/util/TerseFailure.java
index 2c4e41bebe3..53691723ce5 100644
--- a/core/src/main/scala/kafka/tools/TerseFailure.scala
+++ b/server/src/main/java/org/apache/kafka/server/util/TerseFailure.java
@@ -1,10 +1,10 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
+ * contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@@ -15,18 +15,25 @@
* limitations under the License.
*/
-package kafka.tools
+package org.apache.kafka.server.util;
-import org.apache.kafka.common.KafkaException
+import org.apache.kafka.common.KafkaException;
/**
* An exception thrown to indicate that the command has failed, but we don't
want to
* print a stack trace.
- *
- * @param message The message to print out before exiting. A stack trace
will not
- * be printed.
- * @param cause The exception's cause
*/
-class TerseFailure(message: String, cause: Throwable) extends
KafkaException(message, cause) {
- def this(message: String) = this(message, null)
+public class TerseFailure extends KafkaException {
+ public TerseFailure(String message) {
+ super(message);
+ }
+
+ /**
+ * @param message The message to print out before exiting. A stack
trace will not
+ * be printed.
+ * @param cause The exception's cause
+ */
+ public TerseFailure(String message, Throwable cause) {
+ super(message, cause);
+ }
}
diff --git a/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java
b/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java
index 0614d268f54..ecec630669f 100644
--- a/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java
+++ b/shell/src/main/java/org/apache/kafka/shell/MetadataShell.java
@@ -17,8 +17,6 @@
package org.apache.kafka.shell;
-import kafka.tools.TerseFailure;
-
import org.apache.kafka.common.utils.Exit;
import org.apache.kafka.common.utils.Utils;
import org.apache.kafka.image.loader.MetadataLoader;
@@ -28,6 +26,7 @@ import
org.apache.kafka.server.config.DefaultSupportedConfigChecker;
import org.apache.kafka.server.fault.FaultHandler;
import org.apache.kafka.server.fault.LoggingFaultHandler;
import org.apache.kafka.server.util.FileLock;
+import org.apache.kafka.server.util.TerseFailure;
import org.apache.kafka.shell.command.Commands;
import org.apache.kafka.shell.state.MetadataShellPublisher;
import org.apache.kafka.shell.state.MetadataShellState;