Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#1745] improvement(api): Add errorprone plugin to format exception message (#1746)

Peidian li3617a799d8dc
diff --git a/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java b/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java
index eed0858944..655c419d2b 100644
--- a/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java
+++ b/api/src/main/java/com/datastrato/gravitino/NameIdentifier.java
@@ -7,6 +7,8 @@ package com.datastrato.gravitino;
import com.datastrato.gravitino.exceptions.IllegalNameIdentifierException;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
import java.util.Arrays;
/**
@@ -237,9 +239,10 @@ public class NameIdentifier {
* @param message The message to throw.
* @param args The arguments to the message.
*/
- public static void check(boolean condition, String message, Object... args) {
+ @FormatMethod
+ public static void check(boolean condition, @FormatString String message, Object... args) {
if (!condition) {
- throw new IllegalNameIdentifierException(String.format(message, args));
+ throw new IllegalNameIdentifierException(message, args);
}
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/Namespace.java b/api/src/main/java/com/datastrato/gravitino/Namespace.java
index 32f113ae5b..e47f2fca33 100644
--- a/api/src/main/java/com/datastrato/gravitino/Namespace.java
+++ b/api/src/main/java/com/datastrato/gravitino/Namespace.java
@@ -6,6 +6,8 @@ package com.datastrato.gravitino;
import com.datastrato.gravitino.exceptions.IllegalNamespaceException;
import com.google.common.base.Joiner;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
import java.util.Arrays;
/**
@@ -112,8 +114,8 @@ public class Namespace {
public static void checkMetalake(Namespace namespace) {
check(
namespace != null && namespace.isEmpty(),
- String.format(
- "Metalake namespace must be non-null and empty, the input namespace is %s", namespace));
+ "Metalake namespace must be non-null and empty, the input namespace is %s",
+ namespace);
}
/**
@@ -125,9 +127,8 @@ public class Namespace {
public static void checkCatalog(Namespace namespace) {
check(
namespace != null && namespace.length() == 1,
- String.format(
- "Catalog namespace must be non-null and have 1 level, the input namespace is %s",
- namespace));
+ "Catalog namespace must be non-null and have 1 level, the input namespace is %s",
+ namespace);
}
/**
@@ -139,9 +140,8 @@ public class Namespace {
public static void checkSchema(Namespace namespace) {
check(
namespace != null && namespace.length() == 2,
- String.format(
- "Schema namespace must be non-null and have 2 levels, the input namespace is %s",
- namespace));
+ "Schema namespace must be non-null and have 2 levels, the input namespace is %s",
+ namespace);
}
/**
@@ -153,9 +153,8 @@ public class Namespace {
public static void checkTable(Namespace namespace) {
check(
namespace != null && namespace.length() == 3,
- String.format(
- "Table namespace must be non-null and have 3 levels, the input namespace is %s",
- namespace));
+ "Table namespace must be non-null and have 3 levels, the input namespace is %s",
+ namespace);
}
private Namespace(String[] levels) {
@@ -227,9 +226,10 @@ public class Namespace {
* @param message The message to throw.
* @param args The arguments to the message.
*/
- public static void check(boolean expression, String message, Object... args) {
+ @FormatMethod
+ public static void check(boolean expression, @FormatString String message, Object... args) {
if (!expression) {
- throw new IllegalNamespaceException(String.format(message, args));
+ throw new IllegalNamespaceException(message, args);
}
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java
index 52d427a443..b1414f45c5 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/AlreadyExistsException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when an entity or resource already exists. */
public class AlreadyExistsException extends GravitinoRuntimeException {
@@ -11,18 +14,22 @@ public class AlreadyExistsException extends GravitinoRuntimeException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public AlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public AlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public AlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public AlreadyExistsException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java
index f40dafabef..4876a3eda6 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/BadRequestException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when the request is invalid. */
public class BadRequestException extends GravitinoRuntimeException {
@@ -11,18 +14,22 @@ public class BadRequestException extends GravitinoRuntimeException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public BadRequestException(String message) {
- super(message);
+ @FormatMethod
+ public BadRequestException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public BadRequestException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public BadRequestException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java
index c2642981e0..3562575192 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/CatalogAlreadyExistsException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a resource already exists. */
public class CatalogAlreadyExistsException extends AlreadyExistsException {
@@ -11,18 +14,22 @@ public class CatalogAlreadyExistsException extends AlreadyExistsException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public CatalogAlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public CatalogAlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public CatalogAlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public CatalogAlreadyExistsException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java
index ae350a2832..cd9fb4db27 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/FilesetAlreadyExistsException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a file with specified name already exists. */
public class FilesetAlreadyExistsException extends AlreadyExistsException {
@@ -11,18 +14,23 @@ public class FilesetAlreadyExistsException extends AlreadyExistsException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public FilesetAlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public FilesetAlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public FilesetAlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public FilesetAlreadyExistsException(
+ Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java
index 2306e75f83..77706ff924 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/GravitinoRuntimeException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Base class for all Gravitino runtime exceptions. */
public class GravitinoRuntimeException extends RuntimeException {
@@ -17,12 +20,25 @@ public class GravitinoRuntimeException extends RuntimeException {
}
/**
- * Constructs a new exception with the specified detail message and cause.
+ * Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
+ */
+ @FormatMethod
+ public GravitinoRuntimeException(@FormatString String message, Object... args) {
+ super(String.format(message, args));
+ }
+
+ /**
+ * Constructs a new exception with the specified detail message and cause.
+ *
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public GravitinoRuntimeException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public GravitinoRuntimeException(Throwable cause, @FormatString String message, Object... args) {
+ super(String.format(message, args), cause);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java
index cec746c5d5..a73ee5efb0 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNameIdentifierException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a name identifier is invalid. */
public class IllegalNameIdentifierException extends IllegalArgumentException {
@@ -11,19 +14,24 @@ public class IllegalNameIdentifierException extends IllegalArgumentException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public IllegalNameIdentifierException(String message) {
- super(message);
+ @FormatMethod
+ public IllegalNameIdentifierException(@FormatString String message, Object... args) {
+ super(String.format(message, args));
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public IllegalNameIdentifierException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public IllegalNameIdentifierException(
+ Throwable cause, @FormatString String message, Object... args) {
+ super(String.format(message, args), cause);
}
/**
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java
index ed38976789..4d6d2d87e7 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/IllegalNamespaceException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a namespace is invalid. */
public class IllegalNamespaceException extends IllegalArgumentException {
@@ -11,19 +14,23 @@ public class IllegalNamespaceException extends IllegalArgumentException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public IllegalNamespaceException(String message) {
- super(message);
+ @FormatMethod
+ public IllegalNamespaceException(@FormatString String message, Object... args) {
+ super(String.format(message, args));
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public IllegalNamespaceException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public IllegalNamespaceException(Throwable cause, @FormatString String message, Object... args) {
+ super(String.format(message, args), cause);
}
/**
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java
index d0c464bb4e..22efd56592 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/MetalakeAlreadyExistsException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when the metalake already exists. */
public class MetalakeAlreadyExistsException extends AlreadyExistsException {
@@ -11,18 +14,23 @@ public class MetalakeAlreadyExistsException extends AlreadyExistsException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public MetalakeAlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public MetalakeAlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public MetalakeAlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public MetalakeAlreadyExistsException(
+ Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java
index 19c684b31f..c80dc3e4c8 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchCatalogException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a catalog is not found. */
public class NoSuchCatalogException extends NotFoundException {
@@ -11,18 +14,22 @@ public class NoSuchCatalogException extends NotFoundException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchCatalogException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchCatalogException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchCatalogException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchCatalogException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java
index f2a645de92..3f662b305a 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.java
@@ -4,25 +4,31 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a column with specified name is not existed. */
public class NoSuchColumnException extends NotFoundException {
-
/**
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchColumnException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchColumnException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchColumnException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchColumnException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchEntityException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchEntityException.java
index d527457d9e..8a62595702 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchEntityException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchEntityException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** This exception is thrown when an entity is not found. */
public class NoSuchEntityException extends RuntimeException {
@@ -11,9 +14,11 @@ public class NoSuchEntityException extends RuntimeException {
* Constructs a new NoSuchEntityException.
*
* @param message The detail message.
+ * @param args The argument of the formatted message.
*/
- public NoSuchEntityException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchEntityException(@FormatString String message, Object... args) {
+ super(String.format(message, args));
}
/**
@@ -21,8 +26,10 @@ public class NoSuchEntityException extends RuntimeException {
*
* @param message The detail message.
* @param cause The cause of the exception.
+ * @param args The argument of the formatted message.
*/
- public NoSuchEntityException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchEntityException(Throwable cause, @FormatString String message, Object... args) {
+ super(String.format(message, args), cause);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java
index 6d05d0c9e9..660e5f3902 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchFilesetException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a file with specified name is not existed. */
public class NoSuchFilesetException extends NotFoundException {
@@ -11,18 +14,22 @@ public class NoSuchFilesetException extends NotFoundException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchFilesetException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchFilesetException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchFilesetException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchFilesetException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java
index 351a0b69ea..bb9b311e54 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchMetalakeException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a metalake is not found. */
public class NoSuchMetalakeException extends NotFoundException {
@@ -11,18 +14,22 @@ public class NoSuchMetalakeException extends NotFoundException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchMetalakeException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchMetalakeException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchMetalakeException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchMetalakeException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java
index c108268ed2..a10be95033 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchPartitionException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a partition with specified name is not existed. */
public class NoSuchPartitionException extends NotFoundException {
@@ -11,18 +14,22 @@ public class NoSuchPartitionException extends NotFoundException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchPartitionException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchPartitionException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchPartitionException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchPartitionException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java
index cc79172672..df897dda33 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchSchemaException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a schema is not found. */
public class NoSuchSchemaException extends NotFoundException {
@@ -11,18 +14,22 @@ public class NoSuchSchemaException extends NotFoundException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchSchemaException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchSchemaException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchSchemaException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchSchemaException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java
index 0ae7c838bd..63a52a90cc 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchTableException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a table with specified name is not existed. */
public class NoSuchTableException extends NotFoundException {
@@ -11,18 +14,22 @@ public class NoSuchTableException extends NotFoundException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchTableException(String message) {
- super(message);
+ @FormatMethod
+ public NoSuchTableException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NoSuchTableException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NoSuchTableException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java
index c63a202c8d..5a51debeba 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptyEntityException.java
@@ -5,25 +5,31 @@
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when a resource is not empty. */
public class NonEmptyEntityException extends GravitinoRuntimeException {
-
/**
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NonEmptyEntityException(String message) {
- super(message);
+ @FormatMethod
+ public NonEmptyEntityException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NonEmptyEntityException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NonEmptyEntityException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java
index 59d708d7f2..af2516fe63 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NonEmptySchemaException.java
@@ -4,25 +4,31 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a namespace is not empty. */
public class NonEmptySchemaException extends GravitinoRuntimeException {
-
/**
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NonEmptySchemaException(String message) {
- super(message);
+ @FormatMethod
+ public NonEmptySchemaException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public NonEmptySchemaException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NonEmptySchemaException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java
index 2a98e55371..5a46e2c8fc 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/NotFoundException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Base class for all exceptions thrown when a resource is not found. */
public class NotFoundException extends GravitinoRuntimeException {
@@ -11,18 +14,22 @@ public class NotFoundException extends GravitinoRuntimeException {
* Constructs a new NotFoundException.
*
* @param message The detail message.
+ * @param args The arguments to the message.
*/
- public NotFoundException(String message) {
- super(message);
+ @FormatMethod
+ public NotFoundException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new NotFoundException.
*
- * @param message The detail message.
* @param cause The cause of the exception.
+ * @param message The detail message.
+ * @param args The arguments to the message.
*/
- public NotFoundException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public NotFoundException(Throwable cause, String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java
index 2050796596..3f0cc96fb2 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/PartitionAlreadyExistsException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a partition with specified name already exists. */
public class PartitionAlreadyExistsException extends AlreadyExistsException {
@@ -11,18 +14,23 @@ public class PartitionAlreadyExistsException extends AlreadyExistsException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public PartitionAlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public PartitionAlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public PartitionAlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public PartitionAlreadyExistsException(
+ Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java
index e30c6e22f8..260dab2b69 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/RESTException.java
@@ -19,6 +19,7 @@
package com.datastrato.gravitino.exceptions;
import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
// Referred from Apache Iceberg's RESTException implementation
// api/src/main/java/org/apache/iceberg/exceptions/RESTException.java
@@ -33,7 +34,7 @@ public class RESTException extends RuntimeException {
* @param args the arguments to the message.
*/
@FormatMethod
- public RESTException(String message, Object... args) {
+ public RESTException(@FormatString String message, Object... args) {
super(String.format(message, args));
}
@@ -45,7 +46,7 @@ public class RESTException extends RuntimeException {
* @param args the arguments to the message.
*/
@FormatMethod
- public RESTException(Throwable cause, String message, Object... args) {
+ public RESTException(Throwable cause, @FormatString String message, Object... args) {
super(String.format(message, args), cause);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java
index 0552c41261..45bf6cdb0e 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/SchemaAlreadyExistsException.java
@@ -4,6 +4,9 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** An exception thrown when the schema already exists. */
public class SchemaAlreadyExistsException extends AlreadyExistsException {
@@ -11,18 +14,23 @@ public class SchemaAlreadyExistsException extends AlreadyExistsException {
* Constructs a new SchemaAlreadyExistsException.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public SchemaAlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public SchemaAlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new SchemaAlreadyExistsException.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public SchemaAlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public SchemaAlreadyExistsException(
+ Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java
index d2071629d4..5c09ed806d 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/TableAlreadyExistsException.java
@@ -4,25 +4,32 @@
*/
package com.datastrato.gravitino.exceptions;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
+
/** Exception thrown when a table with specified name already exists. */
public class TableAlreadyExistsException extends AlreadyExistsException {
-
/**
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public TableAlreadyExistsException(String message) {
- super(message);
+ @FormatMethod
+ public TableAlreadyExistsException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public TableAlreadyExistsException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public TableAlreadyExistsException(
+ Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java b/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java
index d59ee33041..e32ba66755 100644
--- a/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java
+++ b/api/src/main/java/com/datastrato/gravitino/exceptions/UnauthorizedException.java
@@ -6,6 +6,8 @@
package com.datastrato.gravitino.exceptions;
import com.google.common.collect.Lists;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
import java.util.List;
/** Exception thrown when a user is not authorized to perform an action. */
@@ -18,19 +20,23 @@ public class UnauthorizedException extends GravitinoRuntimeException {
* Constructs a new exception with the specified detail message.
*
* @param message the detail message.
+ * @param args the arguments to the message.
*/
- public UnauthorizedException(String message) {
- super(message);
+ @FormatMethod
+ public UnauthorizedException(@FormatString String message, Object... args) {
+ super(message, args);
}
/**
* Constructs a new exception with the specified detail message and cause.
*
- * @param message the detail message.
* @param cause the cause.
+ * @param message the detail message.
+ * @param args the arguments to the message.
*/
- public UnauthorizedException(String message, Throwable cause) {
- super(message, cause);
+ @FormatMethod
+ public UnauthorizedException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
/**
diff --git a/api/src/main/java/com/datastrato/gravitino/rel/partitions/Partitions.java b/api/src/main/java/com/datastrato/gravitino/rel/partitions/Partitions.java
index 926e3441b5..a0b32fa1b4 100644
--- a/api/src/main/java/com/datastrato/gravitino/rel/partitions/Partitions.java
+++ b/api/src/main/java/com/datastrato/gravitino/rel/partitions/Partitions.java
@@ -5,7 +5,6 @@
package com.datastrato.gravitino.rel.partitions;
import com.datastrato.gravitino.rel.expressions.literals.Literal;
-import com.datastrato.gravitino.rel.expressions.transforms.Transforms;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
@@ -30,9 +29,6 @@ public class Partitions {
/**
* Creates a list partition.
*
- * <p>Each list in the lists must have the same length. The values in each list must correspond to
- * the field definitions in the {@link Transforms.ListTransform#fieldNames()}.
- *
* @param name The name of the partition.
* @param lists The values of the list partition.
* @param properties The properties of the partition.
diff --git a/build.gradle.kts b/build.gradle.kts
index 38219ec8d0..946c5da9bc 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -9,6 +9,7 @@ import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.InventoryHtmlReportRenderer
import com.github.jk1.license.render.ReportRenderer
import com.github.vlsi.gradle.dsl.configureEach
+import net.ltgt.gradle.errorprone.errorprone
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.internal.hash.ChecksumService
import org.gradle.internal.os.OperatingSystem
@@ -44,6 +45,7 @@ plugins {
alias(libs.plugins.bom)
alias(libs.plugins.dependencyLicenseReport)
alias(libs.plugins.tasktree)
+ alias(libs.plugins.errorprone)
}
if (extra["jdkVersion"] !in listOf("8", "11", "17")) {
@@ -201,6 +203,22 @@ subprojects {
}
}
+ if (project.name != "meta") {
+ apply(plugin = "net.ltgt.errorprone")
+ dependencies {
+ errorprone("com.google.errorprone:error_prone_core:2.10.0")
+ }
+
+ tasks.withType<JavaCompile>().configureEach {
+ options.errorprone.isEnabled.set(true)
+ options.errorprone.disableAllChecks.set(true)
+ options.errorprone.enable(
+ "AnnotateFormatMethod",
+ "FormatStringAnnotation"
+ )
+ }
+ }
+
tasks.withType<Javadoc> {
options.encoding = "UTF-8"
options.locale = "en_US"
diff --git a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java
index 15d9fcb430..587f8d1898 100644
--- a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java
+++ b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java
@@ -107,7 +107,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
try {
NameIdentifier schemaIdent = NameIdentifier.of(namespace.levels());
if (!store.exists(schemaIdent, Entity.EntityType.SCHEMA)) {
- throw new NoSuchSchemaException("Schema " + schemaIdent + " does not exist");
+ throw new NoSuchSchemaException("Schema %s does not exist", schemaIdent);
}
List<FilesetEntity> filesets =
@@ -136,9 +136,9 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
.build();
} catch (NoSuchEntityException exception) {
- throw new NoSuchFilesetException("Fileset " + ident + " does not exist", exception);
+ throw new NoSuchFilesetException(exception, "Fileset %s does not exist", ident);
} catch (IOException ioe) {
- throw new RuntimeException("Failed to load fileset " + ident, ioe);
+ throw new RuntimeException("Failed to load fileset %s" + ident, ioe);
}
}
@@ -152,7 +152,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
throws NoSuchSchemaException, FilesetAlreadyExistsException {
try {
if (store.exists(ident, Entity.EntityType.FILESET)) {
- throw new FilesetAlreadyExistsException("Fileset " + ident + " already exists");
+ throw new FilesetAlreadyExistsException("Fileset %s already exists", ident);
}
} catch (IOException ioe) {
throw new RuntimeException("Failed to check if fileset " + ident + " exists", ioe);
@@ -163,7 +163,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
try {
schemaEntity = store.get(schemaIdent, Entity.EntityType.SCHEMA, SchemaEntity.class);
} catch (NoSuchEntityException exception) {
- throw new NoSuchSchemaException("Schema " + schemaIdent + " does not exist", exception);
+ throw new NoSuchSchemaException(exception, "Schema %s does not exist", schemaIdent);
} catch (IOException ioe) {
throw new RuntimeException("Failed to load schema " + schemaIdent, ioe);
}
@@ -250,7 +250,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
throws NoSuchFilesetException, IllegalArgumentException {
try {
if (!store.exists(ident, Entity.EntityType.FILESET)) {
- throw new NoSuchFilesetException("Fileset " + ident + " does not exist");
+ throw new NoSuchFilesetException("Fileset %s does not exist", ident);
}
} catch (IOException ioe) {
throw new RuntimeException("Failed to load fileset " + ident, ioe);
@@ -276,7 +276,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
} catch (IOException ioe) {
throw new RuntimeException("Failed to update fileset " + ident, ioe);
} catch (NoSuchEntityException nsee) {
- throw new NoSuchFilesetException("Fileset " + ident + " does not exist", nsee);
+ throw new NoSuchFilesetException(nsee, "Fileset %s does not exist", ident);
} catch (AlreadyExistsException aee) {
// This is happened when renaming a fileset to an existing fileset name.
throw new RuntimeException(
@@ -332,7 +332,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
throws NoSuchCatalogException, SchemaAlreadyExistsException {
try {
if (store.exists(ident, Entity.EntityType.SCHEMA)) {
- throw new SchemaAlreadyExistsException("Schema " + ident + " already exists");
+ throw new SchemaAlreadyExistsException("Schema %s already exists", ident);
}
} catch (IOException ioe) {
throw new RuntimeException("Failed to check if schema " + ident + " exists", ioe);
@@ -402,7 +402,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
.build();
} catch (NoSuchEntityException exception) {
- throw new NoSuchSchemaException("Schema " + ident + " does not exist", exception);
+ throw new NoSuchSchemaException(exception, "Schema %s does not exist", ident);
} catch (IOException ioe) {
throw new RuntimeException("Failed to load schema " + ident, ioe);
}
@@ -413,7 +413,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
throws NoSuchSchemaException {
try {
if (!store.exists(ident, Entity.EntityType.SCHEMA)) {
- throw new NoSuchSchemaException("Schema " + ident + " does not exist");
+ throw new NoSuchSchemaException("Schema %s does not exist", ident);
}
} catch (IOException ioe) {
throw new RuntimeException("Failed to check if schema " + ident + " exists", ioe);
@@ -437,7 +437,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
} catch (IOException ioe) {
throw new RuntimeException("Failed to update schema " + ident, ioe);
} catch (NoSuchEntityException nsee) {
- throw new NoSuchSchemaException("Schema " + ident + " does not exist", nsee);
+ throw new NoSuchSchemaException(nsee, "Schema %s does not exist", ident);
} catch (AlreadyExistsException aee) {
throw new RuntimeException(
"Schema with the same name "
@@ -468,7 +468,7 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchem
if (fs.listStatus(schemaPath).length > 0 && !cascade) {
throw new NonEmptySchemaException(
- "Schema " + ident + " with location " + schemaPath + " is not empty");
+ "Schema %s with location %s is not empty", ident, schemaPath);
} else {
fs.delete(schemaPath, true);
}
diff --git a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java
index 08a2da45f9..df193a5c64 100644
--- a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java
+++ b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveCatalogOperations.java
@@ -338,9 +338,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
} catch (AlreadyExistsException e) {
throw new SchemaAlreadyExistsException(
- String.format(
- "Hive schema (database) '%s' already exists in Hive Metastore", ident.name()),
- e);
+ e, "Hive schema (database) '%s' already exists in Hive Metastore", ident.name());
} catch (TException e) {
throw new RuntimeException(
@@ -369,9 +367,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
} catch (NoSuchObjectException | UnknownDBException e) {
throw new NoSuchSchemaException(
- String.format(
- "Hive schema (database) does not exist: %s in Hive Metastore", ident.name()),
- e);
+ e, "Hive schema (database) does not exist: %s in Hive Metastore", ident.name());
} catch (TException e) {
throw new RuntimeException(
@@ -432,8 +428,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
} catch (NoSuchObjectException e) {
throw new NoSuchSchemaException(
- String.format("Hive schema (database) %s does not exist in Hive Metastore", ident.name()),
- e);
+ e, "Hive schema (database) %s does not exist in Hive Metastore", ident.name());
} catch (TException | InterruptedException e) {
throw new RuntimeException(
@@ -465,9 +460,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
} catch (InvalidOperationException e) {
throw new NonEmptySchemaException(
- String.format(
- "Hive schema (database) %s is not empty. One or more tables exist.", ident.name()),
- e);
+ e, "Hive schema (database) %s is not empty. One or more tables exist.", ident.name());
} catch (NoSuchObjectException e) {
LOG.warn("Hive schema (database) {} does not exist in Hive Metastore", ident.name());
@@ -493,7 +486,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
public NameIdentifier[] listTables(Namespace namespace) throws NoSuchSchemaException {
NameIdentifier schemaIdent = NameIdentifier.of(namespace.levels());
if (!schemaExists(schemaIdent)) {
- throw new NoSuchSchemaException("Schema (database) does not exist " + namespace);
+ throw new NoSuchSchemaException("Schema (database) does not exist %s", namespace);
}
try {
@@ -517,7 +510,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
.toArray(NameIdentifier[]::new));
} catch (UnknownDBException e) {
throw new NoSuchSchemaException(
- "Schema (database) does not exist " + namespace + " in Hive Metastore");
+ "Schema (database) does not exist %s in Hive Metastore", namespace);
} catch (TException e) {
throw new RuntimeException(
@@ -558,7 +551,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
} catch (NoSuchObjectException e) {
throw new NoSuchTableException(
- String.format("Hive table does not exist: %s in Hive Metastore", tableIdent.name()), e);
+ e, "Hive table does not exist: %s in Hive Metastore", tableIdent.name());
} catch (InterruptedException | TException e) {
throw new RuntimeException(
@@ -711,7 +704,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
try {
if (!schemaExists(schemaIdent)) {
LOG.warn("Hive schema (database) does not exist: {}", schemaIdent);
- throw new NoSuchSchemaException("Hive Schema (database) does not exist " + schemaIdent);
+ throw new NoSuchSchemaException("Hive Schema (database) does not exist: %s ", schemaIdent);
}
HiveTable hiveTable =
@@ -742,7 +735,7 @@ public class HiveCatalogOperations implements CatalogOperations, SupportsSchemas
return hiveTable;
} catch (AlreadyExistsException e) {
- throw new TableAlreadyExistsException("Table already exists: " + tableIdent.name(), e);
+ throw new TableAlreadyExistsException(e, "Table already exists: %s", tableIdent.name());
} catch (TException | InterruptedException e) {
throw new RuntimeException(
"Failed to create Hive table " + tableIdent.name() + " in Hive Metastore", e);
diff --git a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveTableOperations.java b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveTableOperations.java
index 721996aec9..3889f141dd 100644
--- a/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveTableOperations.java
+++ b/catalogs/catalog-hive/src/main/java/com/datastrato/gravitino/catalog/hive/HiveTableOperations.java
@@ -91,11 +91,11 @@ public class HiveTableOperations implements TableOperations, SupportsPartitions
} catch (UnknownTableException e) {
throw new NoSuchTableException(
- "Hive table " + table.name() + " does not exist in Hive Metastore", e);
+ e, "Hive table %s does not exist in Hive Metastore", table.name());
} catch (NoSuchObjectException e) {
throw new NoSuchPartitionException(
- "Hive partition " + partitionName + " does not exist in Hive Metastore", e);
+ e, "Hive partition %s does not exist in Hive Metastore", partitionName);
} catch (TException | InterruptedException e) {
throw new RuntimeException(
diff --git a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/converter/JdbcExceptionConverter.java b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/converter/JdbcExceptionConverter.java
index 67a6785fb6..1081798402 100644
--- a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/converter/JdbcExceptionConverter.java
+++ b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/converter/JdbcExceptionConverter.java
@@ -17,9 +17,10 @@ public abstract class JdbcExceptionConverter {
* @return A best attempt at a corresponding connector exception or generic with the SQLException
* as the cause
*/
+ @SuppressWarnings("FormatStringAnnotation")
public GravitinoRuntimeException toGravitinoException(final SQLException sqlException) {
// TODO we need to transform specific SQL exceptions into our own exceptions, such as
// SchemaAlreadyExistsException
- return new GravitinoRuntimeException(sqlException.getMessage(), sqlException);
+ return new GravitinoRuntimeException(sqlException, sqlException.getMessage());
}
}
diff --git a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java
index 1a20d6534e..92a417957d 100644
--- a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java
+++ b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/operation/JdbcTableOperations.java
@@ -142,8 +142,7 @@ public abstract class JdbcTableOperations implements TableOperation {
}
if (!found) {
- throw new NoSuchTableException(
- String.format("Table %s does not exist in %s.", tableName, databaseName));
+ throw new NoSuchTableException("Table %s does not exist in %s.", tableName, databaseName);
}
// 2.Get column information
@@ -390,7 +389,7 @@ public abstract class JdbcTableOperations implements TableOperation {
.orElseThrow(
() ->
new NoSuchColumnException(
- "Column " + colName + " does not exist in table " + jdbcTable.name()));
+ "Column %s does not exist in table %s", colName, jdbcTable.name()));
}
protected Connection getConnection(String catalog) throws SQLException {
diff --git a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/utils/DataSourceUtils.java b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/utils/DataSourceUtils.java
index 04a061f1ad..a84e18cedd 100644
--- a/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/utils/DataSourceUtils.java
+++ b/catalogs/catalog-jdbc-common/src/main/java/com/datastrato/gravitino/catalog/jdbc/utils/DataSourceUtils.java
@@ -32,7 +32,7 @@ public class DataSourceUtils {
try {
return createDBCPDataSource(jdbcConfig);
} catch (Exception exception) {
- throw new GravitinoRuntimeException("Error creating datasource", exception);
+ throw new GravitinoRuntimeException(exception, "Error creating datasource");
}
}
diff --git a/catalogs/catalog-jdbc-common/src/test/java/com/datastrato/gravitino/catalog/jdbc/converter/SqliteExceptionConverter.java b/catalogs/catalog-jdbc-common/src/test/java/com/datastrato/gravitino/catalog/jdbc/converter/SqliteExceptionConverter.java
index a770695e0f..db59591d60 100644
--- a/catalogs/catalog-jdbc-common/src/test/java/com/datastrato/gravitino/catalog/jdbc/converter/SqliteExceptionConverter.java
+++ b/catalogs/catalog-jdbc-common/src/test/java/com/datastrato/gravitino/catalog/jdbc/converter/SqliteExceptionConverter.java
@@ -14,6 +14,7 @@ public class SqliteExceptionConverter extends JdbcExceptionConverter {
public static final int NO_SUCH_TABLE = 1;
public static final int SCHEMA_ALREADY_EXISTS_CODE = 2;
+ @SuppressWarnings("FormatStringAnnotation")
@Override
public GravitinoRuntimeException toGravitinoException(SQLException sqlException) {
if (sqlException.getErrorCode() == NO_SUCH_TABLE) {
diff --git a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlExceptionConverter.java b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlExceptionConverter.java
index 5184a4ca02..c8cea07a85 100644
--- a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlExceptionConverter.java
+++ b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlExceptionConverter.java
@@ -15,21 +15,22 @@ import java.sql.SQLException;
/** Exception converter to gravitino exception for MySQL. */
public class MysqlExceptionConverter extends JdbcExceptionConverter {
+ @SuppressWarnings("FormatStringAnnotation")
@Override
public GravitinoRuntimeException toGravitinoException(SQLException se) {
switch (se.getErrorCode()) {
case 1007:
- return new SchemaAlreadyExistsException(se.getMessage(), se);
+ return new SchemaAlreadyExistsException(se, se.getMessage());
case 1050:
- return new TableAlreadyExistsException(se.getMessage(), se);
+ return new TableAlreadyExistsException(se, se.getMessage());
case 1008:
case 1049:
- return new NoSuchSchemaException(se.getMessage(), se);
+ return new NoSuchSchemaException(se, se.getMessage());
case 1146:
case 1051:
- return new NoSuchTableException(se.getMessage(), se);
+ return new NoSuchTableException(se, se.getMessage());
default:
- return new GravitinoRuntimeException(se.getMessage(), se);
+ return new GravitinoRuntimeException(se, se.getMessage());
}
}
}
diff --git a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
index 400a87ccb0..6aa5f8e627 100644
--- a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
+++ b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlDatabaseOperations.java
@@ -101,8 +101,7 @@ public class MysqlDatabaseOperations extends JdbcDatabaseOperations {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (!resultSet.next()) {
throw new NoSuchSchemaException(
- String.format(
- "Database %s could not be found in information_schema.SCHEMATA", databaseName));
+ "Database %s could not be found in information_schema.SCHEMATA", databaseName);
}
String schemaName = resultSet.getString("SCHEMA_NAME");
// Mysql currently only supports these two attributes
diff --git a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
index e6bb757b41..25cee75040 100644
--- a/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
+++ b/catalogs/catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/operation/MysqlTableOperations.java
@@ -233,7 +233,7 @@ public class MysqlTableOperations extends JdbcTableOperations {
}
throw new NoSuchTableException(
- String.format("Table %s does not exist in %s.", tableName, connection.getCatalog()));
+ "Table %s does not exist in %s.", tableName, connection.getCatalog());
}
}
}
diff --git a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/converter/PostgreSqlExceptionConverter.java b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/converter/PostgreSqlExceptionConverter.java
index 78addc2cc4..bec19f6bc6 100644
--- a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/converter/PostgreSqlExceptionConverter.java
+++ b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/converter/PostgreSqlExceptionConverter.java
@@ -14,6 +14,7 @@ import java.sql.SQLException;
public class PostgreSqlExceptionConverter extends JdbcExceptionConverter {
+ @SuppressWarnings("FormatStringAnnotation")
@Override
public GravitinoRuntimeException toGravitinoException(SQLException se) {
if (null != se.getSQLState()) {
diff --git a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
index b35213ad77..91de3648da 100644
--- a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
+++ b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlSchemaOperations.java
@@ -61,7 +61,7 @@ public class PostgreSqlSchemaOperations extends JdbcDatabaseOperations {
statement.setString(2, database);
try (ResultSet resultSet = statement.executeQuery()) {
if (!resultSet.next()) {
- throw new NoSuchSchemaException("No such schema: " + schema);
+ throw new NoSuchSchemaException("No such schema: %s", schema);
}
String schemaName = resultSet.getString(1);
String comment = getSchemaComment(schema, connection);
diff --git a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java
index 365a1cf755..c749a60043 100644
--- a/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java
+++ b/catalogs/catalog-jdbc-postgresql/src/main/java/com/datastrato/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java
@@ -365,7 +365,7 @@ public class PostgreSqlTableOperations extends JdbcTableOperations {
.findFirst()
.orElse(null);
if (null == column) {
- throw new NoSuchColumnException("Column " + col + " does not exist.");
+ throw new NoSuchColumnException("Column %s does not exist.", col);
}
StringBuilder sqlBuilder = new StringBuilder(ALTER_TABLE + jdbcTable.name());
sqlBuilder
diff --git a/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java b/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java
index 169addc2ac..9c15794c87 100644
--- a/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java
+++ b/catalogs/catalog-lakehouse-iceberg/src/main/java/com/datastrato/gravitino/catalog/lakehouse/iceberg/IcebergCatalogOperations.java
@@ -140,8 +140,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
.toArray(NameIdentifier[]::new);
} catch (NoSuchNamespaceException e) {
throw new NoSuchSchemaException(
- "Failed to list all schemas (database) under namespace : " + namespace + " in Iceberg",
- e);
+ e, "Failed to list all schemas (database) under namespace : %s in Iceberg", namespace);
}
}
@@ -183,13 +182,12 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
return createdSchema;
} catch (org.apache.iceberg.exceptions.AlreadyExistsException e) {
throw new SchemaAlreadyExistsException(
- String.format("Iceberg schema (database) '%s' already exists", ident.name()), e);
+ e, "Iceberg schema (database) '%s' already exists", ident.name());
} catch (NoSuchNamespaceException e) {
throw new NoSuchSchemaException(
- String.format(
- "Iceberg schema (database) does not exist: %s in Gravitino store, This scenario occurs after the creation is completed and reloaded",
- ident.name()),
- e);
+ e,
+ "Iceberg schema (database) does not exist: %s in Gravitino store, This scenario occurs after the creation is completed and reloaded",
+ ident.name());
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -222,9 +220,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
return icebergSchema;
} catch (NoSuchNamespaceException e) {
throw new NoSuchSchemaException(
- String.format(
- "Iceberg schema (database) does not exist: %s in Gravitino store", ident.name()),
- e);
+ e, "Iceberg schema (database) does not exist: %s in Gravitino store", ident.name());
}
}
@@ -285,7 +281,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
return icebergSchema;
} catch (NoSuchNamespaceException e) {
throw new NoSuchSchemaException(
- String.format("Iceberg schema (database) %s does not exist", ident.name()), e);
+ e, "Iceberg schema (database) %s does not exist", ident.name());
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -308,9 +304,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
return true;
} catch (NamespaceNotEmptyException e) {
throw new NonEmptySchemaException(
- String.format(
- "Iceberg schema (database) %s is not empty. One or more tables exist.", ident.name()),
- e);
+ e, "Iceberg schema (database) %s is not empty. One or more tables exist.", ident.name());
} catch (NoSuchNamespaceException e) {
LOG.warn("Iceberg schema (database) {} does not exist", ident.name());
return false;
@@ -337,8 +331,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
NameIdentifier.of(ArrayUtils.add(namespace.levels(), tableIdentifier.name())))
.toArray(NameIdentifier[]::new);
} catch (NoSuchNamespaceException e) {
- throw new NoSuchSchemaException(
- "Schema (database) does not exist " + namespace + " in Iceberg");
+ throw new NoSuchSchemaException("Schema (database) does not exist %s in Iceberg", namespace);
}
}
@@ -361,8 +354,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
LOG.info("Loaded Iceberg table {}", tableIdent.name());
return icebergTable;
} catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
- throw new NoSuchTableException(
- String.format("Iceberg table does not exist: %s", tableIdent.name()), e);
+ throw new NoSuchTableException(e, "Iceberg table does not exist: %s", tableIdent.name());
}
}
@@ -410,8 +402,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
loadTableResponse.validate();
return IcebergTable.fromIcebergTable(loadTableResponse.tableMetadata(), tableIdent.name());
} catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
- throw new NoSuchTableException(
- String.format("Iceberg table does not exist: %s", tableIdent.name()), e);
+ throw new NoSuchTableException(e, "Iceberg table does not exist: %s", tableIdent.name());
}
}
@@ -437,8 +428,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
icebergTableOps.renameTable(renameTableRequest);
return loadTable(NameIdentifier.of(tableIdent.namespace(), renameTable.getNewName()));
} catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
- throw new NoSuchTableException(
- String.format("Iceberg table does not exist: %s", tableIdent.name()), e);
+ throw new NoSuchTableException(e, "Iceberg table does not exist: %s", tableIdent.name());
}
}
@@ -489,7 +479,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
NameIdentifier schemaIdent = NameIdentifier.of(tableIdent.namespace().levels());
if (!schemaExists(schemaIdent)) {
LOG.warn("Iceberg schema (database) does not exist: {}", schemaIdent);
- throw new NoSuchSchemaException("Iceberg Schema (database) does not exist " + schemaIdent);
+ throw new NoSuchSchemaException("Iceberg Schema (database) does not exist %s", schemaIdent);
}
IcebergColumn[] icebergColumns =
Arrays.stream(columns)
@@ -535,7 +525,7 @@ public class IcebergCatalogOperations implements CatalogOperations, SupportsSche
LOG.info("Created Iceberg table {}", tableIdent.name());
return createdTable;
} catch (AlreadyExistsException e) {
- throw new TableAlreadyExistsException("Table already exists: " + tableIdent.name(), e);
+ throw new TableAlreadyExistsException(e, "Table already exists: %s", tableIdent.name());
}
}
diff --git a/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java b/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java
index 70e82584d5..b849fb6f0e 100644
--- a/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java
+++ b/clients/client-java/src/main/java/com/datastrato/gravitino/client/ErrorHandlers.java
@@ -135,6 +135,7 @@ public class ErrorHandlers {
}
/** Error handler specific to Partition operations. */
+ @SuppressWarnings("FormatStringAnnotation")
private static class PartitionErrorHandler extends RestErrorHandler {
private static final ErrorHandler INSTANCE = new PartitionErrorHandler();
@@ -177,6 +178,7 @@ public class ErrorHandlers {
}
/** Error handler specific to Table operations. */
+ @SuppressWarnings("FormatStringAnnotation")
private static class TableErrorHandler extends RestErrorHandler {
private static final ErrorHandler INSTANCE = new TableErrorHandler();
@@ -211,6 +213,7 @@ public class ErrorHandlers {
}
/** Error handler specific to Schema operations. */
+ @SuppressWarnings("FormatStringAnnotation")
private static class SchemaErrorHandler extends RestErrorHandler {
private static final ErrorHandler INSTANCE = new SchemaErrorHandler();
@@ -246,6 +249,7 @@ public class ErrorHandlers {
}
/** Error handler specific to Catalog operations. */
+ @SuppressWarnings("FormatStringAnnotation")
private static class CatalogErrorHandler extends RestErrorHandler {
private static final ErrorHandler INSTANCE = new CatalogErrorHandler();
@@ -278,6 +282,7 @@ public class ErrorHandlers {
}
/** Error handler specific to Metalake operations. */
+ @SuppressWarnings("FormatStringAnnotation")
private static class MetalakeErrorHandler extends RestErrorHandler {
private static final ErrorHandler INSTANCE = new MetalakeErrorHandler();
@@ -338,17 +343,14 @@ public class ErrorHandlers {
switch (errorResponse.getType()) {
case OAuth2ClientUtil.INVALID_CLIENT_ERROR:
throw new UnauthorizedException(
- String.format(
- "Not authorized: %s: %s", errorResponse.getType(), errorResponse.getMessage()));
+ "Not authorized: %s: %s", errorResponse.getType(), errorResponse.getMessage());
case OAuth2ClientUtil.INVALID_REQUEST_ERROR:
case OAuth2ClientUtil.INVALID_GRANT_ERROR:
case OAuth2ClientUtil.UNAUTHORIZED_CLIENT_ERROR:
case OAuth2ClientUtil.UNSUPPORTED_GRANT_TYPE_ERROR:
case OAuth2ClientUtil.INVALID_SCOPE_ERROR:
throw new BadRequestException(
- String.format(
- "Malformed request: %s: %s",
- errorResponse.getType(), errorResponse.getMessage()));
+ "Malformed request: %s: %s", errorResponse.getType(), errorResponse.getMessage());
}
}
super.accept(errorResponse);
diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java
index 41af731b75..1deaa6112d 100644
--- a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java
+++ b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogManager.java
@@ -214,7 +214,7 @@ public class CatalogManager implements SupportsCatalogs, Closeable {
}
if (!metalakeExists) {
- throw new NoSuchMetalakeException("Metalake " + metalakeIdent + " does not exist");
+ throw new NoSuchMetalakeException("Metalake %s does not exist", metalakeIdent);
}
try {
@@ -287,7 +287,7 @@ public class CatalogManager implements SupportsCatalogs, Closeable {
NameIdentifier metalakeIdent = NameIdentifier.of(ident.namespace().levels());
if (!store.exists(metalakeIdent, EntityType.METALAKE)) {
LOG.warn("Metalake {} does not exist", metalakeIdent);
- throw new NoSuchMetalakeException("Metalake " + metalakeIdent + " does not exist");
+ throw new NoSuchMetalakeException("Metalake %s does not exist", metalakeIdent);
}
// TODO: should avoid a race condition here
@@ -296,7 +296,7 @@ public class CatalogManager implements SupportsCatalogs, Closeable {
return wrapper.catalog;
} catch (EntityAlreadyExistsException e1) {
LOG.warn("Catalog {} already exists", ident, e1);
- throw new CatalogAlreadyExistsException("Catalog " + ident + " already exists");
+ throw new CatalogAlreadyExistsException("Catalog %s already exists", ident);
} catch (IllegalArgumentException | NoSuchMetalakeException e2) {
throw e2;
} catch (Exception e3) {
@@ -343,7 +343,7 @@ public class CatalogManager implements SupportsCatalogs, Closeable {
CatalogWrapper catalogWrapper = loadCatalogAndWrap(ident);
if (catalogWrapper == null) {
- throw new NoSuchCatalogException("Catalog " + ident + " does not exist");
+ throw new NoSuchCatalogException("Catalog %s does not exist", ident);
}
try {
@@ -402,7 +402,7 @@ public class CatalogManager implements SupportsCatalogs, Closeable {
} catch (NoSuchEntityException ne) {
LOG.warn("Catalog {} does not exist", ident, ne);
- throw new NoSuchCatalogException("Catalog " + ident + " does not exist");
+ throw new NoSuchCatalogException("Catalog %s does not exist", ident);
} catch (IllegalArgumentException iae) {
LOG.warn("Failed to alter catalog {} with unknown change", ident, iae);
@@ -452,7 +452,7 @@ public class CatalogManager implements SupportsCatalogs, Closeable {
} catch (NoSuchEntityException ne) {
LOG.warn("Catalog {} does not exist", ident, ne);
- throw new NoSuchCatalogException("Catalog " + ident + " does not exist");
+ throw new NoSuchCatalogException("Catalog %s does not exist", ident);
} catch (IOException ioe) {
LOG.error("Failed to load catalog {}", ident, ioe);
diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogOperationDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogOperationDispatcher.java
index 6e7928230b..156a3b64a6 100644
--- a/core/src/main/java/com/datastrato/gravitino/catalog/CatalogOperationDispatcher.java
+++ b/core/src/main/java/com/datastrato/gravitino/catalog/CatalogOperationDispatcher.java
@@ -891,9 +891,8 @@ public class CatalogOperationDispatcher implements TableCatalog, FilesetCatalog,
ident.name() != null, "The name variable in the NameIdentifier must have value.");
Namespace.check(
ident.namespace() != null && ident.namespace().length() > 0,
- String.format(
- "Catalog namespace must be non-null and have 1 level, the input namespace is %s",
- ident.namespace()));
+ "Catalog namespace must be non-null and have 1 level, the input namespace is %s",
+ ident.namespace());
List<String> allElems =
Stream.concat(Arrays.stream(ident.namespace().levels()), Stream.of(ident.name()))
diff --git a/core/src/main/java/com/datastrato/gravitino/meta/MetalakeManager.java b/core/src/main/java/com/datastrato/gravitino/meta/MetalakeManager.java
index 8b90f685cb..59e72ebd3d 100644
--- a/core/src/main/java/com/datastrato/gravitino/meta/MetalakeManager.java
+++ b/core/src/main/java/com/datastrato/gravitino/meta/MetalakeManager.java
@@ -75,7 +75,7 @@ public class MetalakeManager implements SupportsMetalakes {
return store.get(ident, EntityType.METALAKE, BaseMetalake.class);
} catch (NoSuchEntityException e) {
LOG.warn("Metalake {} does not exist", ident, e);
- throw new NoSuchMetalakeException("Metalake " + ident + " does not exist");
+ throw new NoSuchMetalakeException("Metalake %s does not exist", ident);
} catch (IOException ioe) {
LOG.error("Loading Metalake {} failed due to storage issues", ident, ioe);
throw new RuntimeException(ioe);
@@ -118,7 +118,7 @@ public class MetalakeManager implements SupportsMetalakes {
return metalake;
} catch (EntityAlreadyExistsException e) {
LOG.warn("Metalake {} already exists", ident, e);
- throw new MetalakeAlreadyExistsException("Metalake " + ident + " already exists");
+ throw new MetalakeAlreadyExistsException("Metalake %s already exists", ident);
} catch (IOException ioe) {
LOG.error("Loading Metalake {} failed due to storage issues", ident, ioe);
throw new RuntimeException(ioe);
@@ -173,7 +173,7 @@ public class MetalakeManager implements SupportsMetalakes {
} catch (NoSuchEntityException ne) {
LOG.warn("Metalake {} does not exist", ident, ne);
- throw new NoSuchMetalakeException("Metalake " + ident + " does not exist");
+ throw new NoSuchMetalakeException("Metalake %s does not exist", ident);
} catch (IllegalArgumentException iae) {
LOG.warn("Altering Metalake {} failed due to invalid changes", ident, iae);
diff --git a/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutException.java b/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutException.java
index c9ab2586c0..5e24896c3c 100644
--- a/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutException.java
+++ b/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutException.java
@@ -6,14 +6,31 @@
package com.datastrato.gravitino.storage;
import com.datastrato.gravitino.exceptions.GravitinoRuntimeException;
+import com.google.errorprone.annotations.FormatMethod;
+import com.google.errorprone.annotations.FormatString;
public class StorageLayoutException extends GravitinoRuntimeException {
- public StorageLayoutException(String message) {
- super(message);
+ /**
+ * Constructs a new StorageLayoutException.
+ *
+ * @param message The detail message.
+ * @param args The argument of the formatted message.
+ */
+ @FormatMethod
+ public StorageLayoutException(@FormatString String message, Object... args) {
+ super(message, args);
}
- public StorageLayoutException(String message, Throwable cause) {
- super(message, cause);
+ /**
+ * Constructs a new StorageLayoutException.
+ *
+ * @param cause The cause of the exception.
+ * @param message The detail message.
+ * @param args The argument of the formatted message.
+ */
+ @FormatMethod
+ public StorageLayoutException(Throwable cause, @FormatString String message, Object... args) {
+ super(cause, message, args);
}
}
diff --git a/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutVersion.java b/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutVersion.java
index 4171c36629..f469671488 100644
--- a/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutVersion.java
+++ b/core/src/main/java/com/datastrato/gravitino/storage/StorageLayoutVersion.java
@@ -25,7 +25,6 @@ public enum StorageLayoutVersion {
}
}
throw new StorageLayoutException(
- "Unknown storage version, maybe the data is broken, please "
- + "check the storage directory.");
+ "Unknown storage version, maybe the data is broken, please check the storage directory.");
}
}
diff --git a/core/src/main/java/com/datastrato/gravitino/storage/kv/KvEntityStore.java b/core/src/main/java/com/datastrato/gravitino/storage/kv/KvEntityStore.java
index 18deb7a4cc..fd172e56fd 100644
--- a/core/src/main/java/com/datastrato/gravitino/storage/kv/KvEntityStore.java
+++ b/core/src/main/java/com/datastrato/gravitino/storage/kv/KvEntityStore.java
@@ -186,7 +186,7 @@ public class KvEntityStore implements EntityStore {
byte[] key = entityKeyEncoder.encode(ident, entityType);
byte[] value = transactionalKvBackend.get(key);
if (value == null) {
- throw new NoSuchEntityException(ident.toString());
+ throw new NoSuchEntityException("No such entity:%s", ident.toString());
}
E e = serDe.deserialize(value, type);
@@ -201,9 +201,7 @@ public class KvEntityStore implements EntityStore {
boolean newEntityExist = exists(updatedE.nameIdentifier(), entityType);
if (newEntityExist) {
throw new AlreadyExistsException(
- String.format(
- "Entity %s already exist, please check again",
- updatedE.nameIdentifier()));
+ "Entity %s already exist, please check again", updatedE.nameIdentifier());
}
// Update the name mapping
@@ -287,13 +285,13 @@ public class KvEntityStore implements EntityStore {
() -> {
byte[] key = entityKeyEncoder.encode(ident, entityType, true);
if (key == null) {
- throw new NoSuchEntityException(ident.toString());
+ throw new NoSuchEntityException("No such entity:%s", ident.toString());
}
return transactionalKvBackend.get(key);
}),
reentrantReadWriteLock);
if (value == null) {
- throw new NoSuchEntityException(ident.toString());
+ throw new NoSuchEntityException("No such entity:%s", ident.toString());
}
return serDe.deserialize(value, e);
}
@@ -389,9 +387,8 @@ public class KvEntityStore implements EntityStore {
}
throw new NonEmptyEntityException(
- String.format(
- "Entity %s has sub-entities %s, you should remove sub-entities first",
- ident, subEntities));
+ "Entity %s has sub-entities %s, you should remove sub-entities first",
+ ident, subEntities);
}
for (byte[] prefix : subEntityPrefix) {
diff --git a/core/src/main/java/com/datastrato/gravitino/storage/kv/RocksDBKvBackend.java b/core/src/main/java/com/datastrato/gravitino/storage/kv/RocksDBKvBackend.java
index 9155af97bf..1823a3741c 100644
--- a/core/src/main/java/com/datastrato/gravitino/storage/kv/RocksDBKvBackend.java
+++ b/core/src/main/java/com/datastrato/gravitino/storage/kv/RocksDBKvBackend.java
@@ -91,9 +91,8 @@ public class RocksDBKvBackend implements KvBackend {
byte[] existKey = db.get(key);
if (existKey != null) {
throw new AlreadyExistsException(
- String.format(
- "Key %s already exists in the database, please use overwrite option to overwrite it",
- ByteUtils.formatByteArray(key)));
+ "Key %s already exists in the database, please use overwrite option to overwrite it",
+ ByteUtils.formatByteArray(key));
}
db.put(key, value);
}
diff --git a/core/src/main/java/com/datastrato/gravitino/storage/relational/RelationalEntityStore.java b/core/src/main/java/com/datastrato/gravitino/storage/relational/RelationalEntityStore.java
index d614d7d7a1..f97cf4c52f 100644
--- a/core/src/main/java/com/datastrato/gravitino/storage/relational/RelationalEntityStore.java
+++ b/core/src/main/java/com/datastrato/gravitino/storage/relational/RelationalEntityStore.java
@@ -96,7 +96,7 @@ public class RelationalEntityStore implements EntityStore {
throws NoSuchEntityException, IOException {
E entity = backend.get(ident, entityType);
if (entity == null) {
- throw new NoSuchEntityException(ident.toString());
+ throw new NoSuchEntityException("No such entity:%s", ident.toString());
}
return entity;
}
diff --git a/core/src/test/java/com/datastrato/gravitino/TestCatalogOperations.java b/core/src/test/java/com/datastrato/gravitino/TestCatalogOperations.java
index 8c82878680..0e44a0034d 100644
--- a/core/src/test/java/com/datastrato/gravitino/TestCatalogOperations.java
+++ b/core/src/test/java/com/datastrato/gravitino/TestCatalogOperations.java
@@ -85,7 +85,7 @@ public class TestCatalogOperations
if (tables.containsKey(ident)) {
return tables.get(ident);
} else {
- throw new NoSuchTableException("Table " + ident + " does not exist");
+ throw new NoSuchTableException("Table %s does not exist", ident);
}
}
@@ -117,7 +117,7 @@ public class TestCatalogOperations
.build();
if (tables.containsKey(ident)) {
- throw new TableAlreadyExistsException("Table " + ident + " already exists");
+ throw new TableAlreadyExistsException("Table %s already exists", ident);
} else {
tables.put(ident, table);
}
@@ -139,7 +139,7 @@ public class TestCatalogOperations
public Table alterTable(NameIdentifier ident, TableChange... changes)
throws NoSuchTableException, IllegalArgumentException {
if (!tables.containsKey(ident)) {
- throw new NoSuchTableException("Table " + ident + " does not exist");
+ throw new NoSuchTableException("Table %s does not exist", ident);
}
AuditInfo updatedAuditInfo =
@@ -219,7 +219,7 @@ public class TestCatalogOperations
.build();
if (schemas.containsKey(ident)) {
- throw new SchemaAlreadyExistsException("Schema " + ident + " already exists");
+ throw new SchemaAlreadyExistsException("Schema %s already exists", ident);
} else {
schemas.put(ident, schema);
}
@@ -232,7 +232,7 @@ public class TestCatalogOperations
if (schemas.containsKey(ident)) {
return schemas.get(ident);
} else {
- throw new NoSuchSchemaException("Schema " + ident + " does not exist");
+ throw new NoSuchSchemaException("Schema %s does not exist", ident);
}
}
@@ -240,7 +240,7 @@ public class TestCatalogOperations
public Schema alterSchema(NameIdentifier ident, SchemaChange... changes)
throws NoSuchSchemaException {
if (!schemas.containsKey(ident)) {
- throw new NoSuchSchemaException("Schema " + ident + " does not exist");
+ throw new NoSuchSchemaException("Schema %s does not exist", ident);
}
AuditInfo updatedAuditInfo =
@@ -398,7 +398,7 @@ public class TestCatalogOperations
if (filesets.containsKey(ident)) {
return filesets.get(ident);
} else {
- throw new NoSuchFilesetException("Fileset " + ident + " does not exist");
+ throw new NoSuchFilesetException("Fileset %s does not exist", ident);
}
}
@@ -423,7 +423,7 @@ public class TestCatalogOperations
.build();
if (tables.containsKey(ident)) {
- throw new FilesetAlreadyExistsException("Fileset " + ident + " already exists");
+ throw new FilesetAlreadyExistsException("Fileset %s already exists", ident);
} else {
filesets.put(ident, fileset);
}
@@ -435,7 +435,7 @@ public class TestCatalogOperations
public Fileset alterFileset(NameIdentifier ident, FilesetChange... changes)
throws NoSuchFilesetException, IllegalArgumentException {
if (!filesets.containsKey(ident)) {
- throw new NoSuchFilesetException("Fileset " + ident + " does not exist");
+ throw new NoSuchFilesetException("Fileset %s does not exist", ident);
}
AuditInfo updatedAuditInfo =
diff --git a/core/src/test/java/com/datastrato/gravitino/TestEntityStore.java b/core/src/test/java/com/datastrato/gravitino/TestEntityStore.java
index 6393854df2..373e78df14 100644
--- a/core/src/test/java/com/datastrato/gravitino/TestEntityStore.java
+++ b/core/src/test/java/com/datastrato/gravitino/TestEntityStore.java
@@ -94,7 +94,7 @@ public class TestEntityStore {
() -> {
E e = (E) entityMap.get(ident);
if (e == null) {
- throw new NoSuchEntityException("Entity " + ident + " does not exist");
+ throw new NoSuchEntityException("Entity %s does not exist", ident);
}
E newE = updater.apply(e);
@@ -113,7 +113,7 @@ public class TestEntityStore {
throws NoSuchEntityException, IOException {
E e = (E) entityMap.get(ident);
if (e == null) {
- throw new NoSuchEntityException("Entity " + ident + " does not exist");
+ throw new NoSuchEntityException("Entity %s does not exist", ident);
}
return e;
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 2cc1aebae0..b683328281 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -56,6 +56,7 @@ kerby = "2.0.3"
node-plugin = "7.0.1"
commons-cli = "1.2"
sun-activation-version = "1.2.0"
+error-prone = "3.1.0"
[libraries]
protobuf-java = { group = "com.google.protobuf", name = "protobuf-java", version.ref = "protoc" }
@@ -167,3 +168,4 @@ node = { id = "com.github.node-gradle.node", version.ref = "node-plugin" }
tasktree = {id = "com.dorongold.task-tree", version = "2.1.1"}
dependencyLicenseReport = {id = "com.github.jk1.dependency-license-report", version = "2.5"}
bom = {id = "org.cyclonedx.bom", version = "1.5.0"}
+errorprone = {id = "net.ltgt.errorprone", version.ref = "error-prone"}
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/service/MysqlService.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/service/MysqlService.java
index 96778bc72b..2732328da3 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/service/MysqlService.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/mysql/service/MysqlService.java
@@ -66,8 +66,7 @@ public class MysqlService {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
if (!resultSet.next()) {
throw new NoSuchSchemaException(
- String.format(
- "Database %s could not be found in information_schema.SCHEMATA", databaseName));
+ "Database %s could not be found in information_schema.SCHEMATA", databaseName);
}
String schemaName = resultSet.getString("SCHEMA_NAME");
return new JdbcSchema.Builder().withName(schemaName).withAuditInfo(AuditInfo.EMPTY).build();
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/postgresql/service/PostgreSqlService.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/postgresql/service/PostgreSqlService.java
index d3ba1bdebc..7629b02f0e 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/postgresql/service/PostgreSqlService.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/jdbc/postgresql/service/PostgreSqlService.java
@@ -70,7 +70,7 @@ public class PostgreSqlService {
statement.setString(2, database);
try (ResultSet resultSet = statement.executeQuery()) {
if (!resultSet.next()) {
- throw new NoSuchSchemaException("No such schema: " + schema);
+ throw new NoSuchSchemaException("No such schema: %s", schema);
}
String schemaName = resultSet.getString(1);
return new JdbcSchema.Builder().withName(schemaName).build();
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceBaseIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceBaseIT.java
index dcc5fdaa9b..041fb5abcb 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceBaseIT.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceBaseIT.java
@@ -14,6 +14,7 @@ import com.datastrato.gravitino.integration.test.util.AbstractIT;
import com.datastrato.gravitino.server.web.JettyServerConfig;
import com.datastrato.gravitino.utils.MapUtils;
import com.google.common.collect.ImmutableList;
+import com.google.errorprone.annotations.FormatMethod;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory;
* <p>Referred from spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/SparkTestBase.java
*/
+@SuppressWarnings("FormatStringAnnotation")
public abstract class IcebergRESTServiceBaseIT extends AbstractIT {
public static final Logger LOG = LoggerFactory.getLogger(IcebergRESTServiceBaseIT.class);
private SparkSession sparkSession;
@@ -115,6 +117,7 @@ public abstract class IcebergRESTServiceBaseIT extends AbstractIT {
}
}
+ @FormatMethod
protected List<Object[]> sql(String query, Object... args) {
List<Row> rows = sparkSession.sql(String.format(query, args)).collectAsList();
if (rows.isEmpty()) {
diff --git a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceIT.java b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceIT.java
index 6a6f684aee..1064a292fa 100644
--- a/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceIT.java
+++ b/integration-test/src/test/java/com/datastrato/gravitino/integration/test/catalog/lakehouse/iceberg/IcebergRESTServiceIT.java
@@ -32,6 +32,7 @@ import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
import org.junit.jupiter.api.condition.EnabledIf;
+@SuppressWarnings("FormatStringAnnotation")
@TestInstance(Lifecycle.PER_CLASS)
public class IcebergRESTServiceIT extends IcebergRESTServiceBaseIT {
diff --git a/server-common/src/main/java/com/datastrato/gravitino/server/auth/OAuth2TokenAuthenticator.java b/server-common/src/main/java/com/datastrato/gravitino/server/auth/OAuth2TokenAuthenticator.java
index f2dfb0288d..6b3d77d2fb 100644
--- a/server-common/src/main/java/com/datastrato/gravitino/server/auth/OAuth2TokenAuthenticator.java
+++ b/server-common/src/main/java/com/datastrato/gravitino/server/auth/OAuth2TokenAuthenticator.java
@@ -73,18 +73,18 @@ class OAuth2TokenAuthenticator implements Authenticator {
if (audienceObject instanceof String) {
if (!serviceAudience.equals(audienceObject)) {
throw new UnauthorizedException(
- "Audience in the token [" + audienceObject + "] doesn't contain " + serviceAudience);
+ "Audience in the token [%s] doesn't contain %s", audienceObject, serviceAudience);
}
} else if (audienceObject instanceof List) {
List<Object> audiences = (List<Object>) audienceObject;
if (audiences.stream()
.noneMatch(audienceInToken -> audienceInToken.equals(serviceAudience))) {
throw new UnauthorizedException(
- "Audiences in the token " + audienceObject + " don't contain " + serviceAudience);
+ "Audiences in the token %s don't contain %s", audienceObject, serviceAudience);
}
} else {
throw new UnauthorizedException(
- "Audiences in token is not in expected format: " + audienceObject);
+ "Audiences in token is not in expected format: %s", audienceObject);
}
return new UserPrincipal(jwt.getBody().getSubject());
} catch (ExpiredJwtException
@@ -92,7 +92,7 @@ class OAuth2TokenAuthenticator implements Authenticator {
| MalformedJwtException
| SignatureException
| IllegalArgumentException e) {
- throw new UnauthorizedException("JWT parse error", e);
+ throw new UnauthorizedException(e, "JWT parse error");
}
}
diff --git a/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestMetalakeOperations.java b/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestMetalakeOperations.java
index 3dd9e41f3f..230229f068 100644
--- a/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestMetalakeOperations.java
+++ b/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestMetalakeOperations.java
@@ -195,7 +195,7 @@ public class TestMetalakeOperations extends JerseyTest {
Assertions.assertNull(metalake1.properties());
// Test when specified metalake is not found.
- doThrow(new NoSuchMetalakeException("Failed to find metalake by name " + metalakeName))
+ doThrow(new NoSuchMetalakeException("Failed to find metalake by name %s", metalakeName))
.when(metalakeManager)
.loadMetalake(any());
@@ -280,7 +280,7 @@ public class TestMetalakeOperations extends JerseyTest {
Assertions.assertNull(metalake1.properties());
// Test when specified metalake is not found.
- doThrow(new NoSuchMetalakeException("Failed to find metalake by name " + metalakeName))
+ doThrow(new NoSuchMetalakeException("Failed to find metalake by name %s", metalakeName))
.when(metalakeManager)
.alterMetalake(any(), any(), any());
diff --git a/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestPartitionOperations.java b/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestPartitionOperations.java
index 85c22ec811..6fc3a0e3c0 100644
--- a/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestPartitionOperations.java
+++ b/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestPartitionOperations.java
@@ -124,6 +124,7 @@ public class TestPartitionOperations extends JerseyTest {
return mockPartitionedTable(table, columns, comment, properties, transforms, partitionNames);
}
+ @SuppressWarnings("FormatStringAnnotation")
private Table mockPartitionedTable(
String tableName,
Column[] columns,