Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void write(JsonWriter jsonWriter, T value) throws IOException {
newThriftSerializer().toString((TBase) value, StandardCharsets.UTF_8.name());
jsonWriter.value(result);
logger.warn(
"TBase message will no longer be support in cadence-java-client V4, payload {}",
result);
"Thrift message will no longer be supported for data convertion in cadence-java-client V4, payload class name {}",
result.getClass().getName());
} catch (TException e) {
throw new DataConverterException("Failed to serialize TBase", e);
}
Expand All @@ -79,13 +79,13 @@ public T read(JsonReader jsonReader) throws IOException {
}
String value = jsonReader.nextString();
try {
logger.warn(
"TBase message will no longer be support in cadence-java-client V4, payload {}",
value);
@SuppressWarnings("unchecked")
T instance = (T) typeToken.getRawType().getConstructor().newInstance();
newThriftDeserializer()
.deserialize((TBase) instance, value, StandardCharsets.UTF_8.name());
logger.warn(
"Thrift message will no longer be supported for data convertion in cadence-java-client V4, payload class name {}",
instance.getClass().getName());
return instance;
} catch (Exception e) {
throw new DataConverterException("Failed to deserialize TBase", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.io.IOException;
import java.lang.reflect.Method;
import org.apache.thrift.TEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Special handling of TEnum serialization and deserialization. This is to support for inline TEnum
Expand All @@ -34,6 +36,8 @@
*/
public class TEnumTypeAdapterFactory implements TypeAdapterFactory {

private static final Logger logger = LoggerFactory.getLogger(TEnumTypeAdapterFactory.class);

@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
// this class only serializes 'TEnum' and its subtypes
Expand All @@ -44,6 +48,9 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
new TypeAdapter<T>() {
@Override
public void write(JsonWriter jsonWriter, T value) throws IOException {
logger.warn(
"Thrift message will no longer be supported for data convertion in cadence-java-client V4, payload class name {}",
value.getClass().getName());
jsonWriter.value(((TEnum) value).getValue());
}

Expand All @@ -54,6 +61,9 @@ public T read(JsonReader jsonReader) throws IOException {
Method m = (typeToken.getRawType().getDeclaredMethod("findByValue", Integer.TYPE));
@SuppressWarnings("unchecked")
T instance = (T) m.invoke(null, value);
logger.warn(
"Thrift message will no longer be supported for data convertion in cadence-java-client V4, payload class name {}",
instance.getClass().getName());
return instance;
} catch (Exception e) {
throw new DataConverterException("Failed to deserilize TEnum", e);
Expand Down