[
https://issues.apache.org/jira/browse/KAFKA-16409?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
PoAn Yang reassigned KAFKA-16409:
---------------------------------
Assignee: PoAn Yang
> kafka-delete-records / DeleteRecordsCommand should use standard exception
> handling
> ----------------------------------------------------------------------------------
>
> Key: KAFKA-16409
> URL: https://issues.apache.org/jira/browse/KAFKA-16409
> Project: Kafka
> Issue Type: Task
> Components: tools
> Affects Versions: 3.7.0
> Reporter: Greg Harris
> Assignee: PoAn Yang
> Priority: Minor
> Labels: newbie
>
> When an exception is thrown in kafka-delete-records, it propagates through
> `main` to the JVM, producing the following message:
> {noformat}
> bin/kafka-delete-records.sh --bootstrap-server localhost:9092
> --offset-json-file /tmp/does-not-exist
> Exception in thread "main" java.io.IOException: Unable to read file
> /tmp/does-not-exist
> at
> org.apache.kafka.common.utils.Utils.readFileAsString(Utils.java:787)
> at
> org.apache.kafka.tools.DeleteRecordsCommand.execute(DeleteRecordsCommand.java:105)
> at
> org.apache.kafka.tools.DeleteRecordsCommand.main(DeleteRecordsCommand.java:64)
> Caused by: java.nio.file.NoSuchFileException: /tmp/does-not-exist
> at
> sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
> at
> sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
> at
> sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
> at
> sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
> at java.nio.file.Files.newByteChannel(Files.java:361)
> at java.nio.file.Files.newByteChannel(Files.java:407)
> at java.nio.file.Files.readAllBytes(Files.java:3152)
> at
> org.apache.kafka.common.utils.Utils.readFileAsString(Utils.java:784)
> ... 2 more{noformat}
> This is in contrast to the error handling used in other tools, such as the
> kafka-log-dirs:
> {noformat}
> bin/kafka-log-dirs.sh --bootstrap-server localhost:9092 --describe
> --command-config /tmp/does-not-exist
> /tmp/does-not-exist
> java.nio.file.NoSuchFileException: /tmp/does-not-exist
> at
> sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
> at
> sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
> at
> sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
> at
> sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
> at java.nio.file.Files.newByteChannel(Files.java:361)
> at java.nio.file.Files.newByteChannel(Files.java:407)
> at
> java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
> at java.nio.file.Files.newInputStream(Files.java:152)
> at org.apache.kafka.common.utils.Utils.loadProps(Utils.java:686)
> at org.apache.kafka.common.utils.Utils.loadProps(Utils.java:673)
> at
> org.apache.kafka.tools.LogDirsCommand.createAdminClient(LogDirsCommand.java:149)
> at
> org.apache.kafka.tools.LogDirsCommand.execute(LogDirsCommand.java:68)
> at
> org.apache.kafka.tools.LogDirsCommand.mainNoExit(LogDirsCommand.java:54)
> at
> org.apache.kafka.tools.LogDirsCommand.main(LogDirsCommand.java:49){noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)