fresh-borzoni commented on code in PR #3447:
URL: https://github.com/apache/fluss/pull/3447#discussion_r3467322111
##########
fluss-client/src/main/java/org/apache/fluss/client/converter/ConverterCommons.java:
##########
@@ -171,13 +180,17 @@ public static String charLengthExceptionMessage(String
fieldName, int length) {
}
static BinaryString toBinaryStringForText(Object v, String fieldName,
DataTypeRoot root) {
- final String s = String.valueOf(v);
+ final String s = objectToString(v);
if (root == DataTypeRoot.CHAR && s.length() != 1) {
throw new
IllegalArgumentException(charLengthExceptionMessage(fieldName, s.length()));
}
return BinaryString.fromString(s);
}
+ private static String objectToString(Object v) {
+ return v != null && v.getClass().isEnum() ? ((Enum<?>) v).name() :
String.valueOf(v);
Review Comment:
v.getClass().isEnum() is false for enum constants with a class body (PLUS {
… } -> anonymous subclass). Those would fall back to toString() and desync from
the read side again. v instanceof Enum covers all constants and is the
idiomatic check.
--
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]