Copilot commented on code in PR #12010:
URL: https://github.com/apache/gravitino/pull/12010#discussion_r3578180505
##########
core/src/main/java/org/apache/gravitino/connector/capability/Capability.java:
##########
@@ -73,6 +74,22 @@ default CapabilityResult caseSensitiveOnName(Scope scope) {
return DEFAULT.caseSensitiveOnName(scope);
}
+ /**
+ * Normalizes the given name to the catalog's canonical form before it is
used to call the
+ * underlying catalog operation and persisted as the Gravitino entity name.
This is invoked
+ * instead of the simple lowercase folding implied by {@link
#caseSensitiveOnName(Scope)} whenever
+ * a catalog needs custom folding logic (for example, a catalog whose native
folding direction is
+ * uppercase, or one that supports a case-sensitive quoted form alongside a
case-insensitive
+ * unquoted form).
+ *
+ * @param scope The scope of the capability.
+ * @param name The name to normalize.
+ * @return The normalized, canonical name.
+ */
+ default String normalizeName(Scope scope, String name) {
+ return caseSensitiveOnName(scope).supported() ? name :
name.toLowerCase(Locale.ROOT);
+ }
Review Comment:
`Capability.normalizeName` has inconsistent behavior for `null` names: it
returns `null` when `caseSensitiveOnName(scope)` is supported, but will throw a
`NullPointerException` when it is unsupported (because of
`name.toLowerCase(...)`). Since `CapabilityHelpers.applyCaseSensitiveOnName`
explicitly allows `null` names to pass through, make the default implementation
explicitly handle `null` inputs to avoid surprising NPEs and to keep
normalization behavior consistent across catalogs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]