zachjsh commented on code in PR #13627:
URL: https://github.com/apache/druid/pull/13627#discussion_r1066343900
##########
server/src/main/java/org/apache/druid/catalog/model/CatalogUtils.java:
##########
@@ -93,15 +100,54 @@ public static <T> T safeCast(Object value, Class<T> type,
String propertyName)
catch (ClassCastException e) {
throw new IAE("Value [%s] is not valid for property %s, expected type
%s",
value,
- propertyName,
+ key,
type.getSimpleName()
);
}
}
- public static <T> T safeGet(Map<String, Object> map, String propertyName,
Class<T> type)
+ public static <T> T safeGet(Map<String, Object> map, String key, Class<T>
type)
{
- return safeCast(map.get(propertyName), type, propertyName);
+ return safeCast(map.get(key), type, key);
+ }
+
+ public static long getLong(Map<String, Object> map, String key)
Review Comment:
Should we catch any `ClassCastException` here as is being done in `safeGet`
and return more friendly error to the user in the case of error?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]