kafka-1797; (addressing Manikumar Reddy's comment) add the serializer/deserializer api to the new java client; patched by Jun Rao; reviewed by Manikumar Reddy and Neha Narkhede
@ -37,6 +37,9 @@ public class StringDeserializer implements Deserializer<String> {
@@ -37,6 +37,9 @@ public class StringDeserializer implements Deserializer<String> {
@Override
publicStringdeserialize(Stringtopic,byte[]data){
try{
if(data==null)
returnnull;
else
returnnewString(data,encoding);
}catch(UnsupportedEncodingExceptione){
thrownewSerializationException("Error when deserializing byte[] to string due to unsupported encoding "+encoding);
@ -37,6 +37,9 @@ public class StringSerializer implements Serializer<String> {
@@ -37,6 +37,9 @@ public class StringSerializer implements Serializer<String> {
@Override
publicbyte[]serialize(Stringtopic,Stringdata){
try{
if(data==null)
returnnull;
else
returndata.getBytes(encoding);
}catch(UnsupportedEncodingExceptione){
thrownewSerializationException("Error when serializing string to byte[] due to unsupported encoding "+encoding);