adoroszlai commented on code in PR #10053:
URL: https://github.com/apache/ozone/pull/10053#discussion_r3039212042
##########
hadoop-ozone/iceberg/src/main/java/org/apache/hadoop/ozone/iceberg/RewriteTablePathOzoneAction.java:
##########
@@ -206,8 +194,17 @@ private String getMetadataLocation(Table tbl) {
metadataDir = currentMetadataPath.substring(0, lastIndex + 1);
}
- Preconditions.checkArgument(
- !metadataDir.isEmpty(), "Failed to get the metadata file root
directory");
+ if (metadataDir.isEmpty()) {
+ throw new IllegalArgumentException("Failed to get the metadata file root
directory");
+ }
return metadataDir;
}
+
+ private static void checkNonNullNonEmpty(String value, String messageFormat)
{
+ String message = String.format(messageFormat, value);
+ Objects.requireNonNull(value, message);
+ if (value.trim().isEmpty()) {
+ throw new IllegalArgumentException(message);
+ }
Review Comment:
Avoid eager formatting. Actually, `value` is always either `null` or `""`,
and we have separate checks for each.
Suggested:
```java
private static void checkNonNullNonEmpty(String value, String name) {
Objects.requireNonNull(value, () -> name + " == null");
if (value.trim().isEmpty()) {
throw new IllegalArgumentException(name + " is empty");
}
}
```
and pass only name e.g. `Source prefix`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]