@@ -384,6 +384,7 @@ func (t *serializerImpl) serialize(input interface{}, encodingType common.Encodi
384384 return nil , nil
385385 }
386386
387+ // This should not pass proto struct down to JSON section.
387388 if p , ok := input .(proto.Marshaler ); ok {
388389 return t .serializeProto (p , encodingType )
389390 }
@@ -394,6 +395,7 @@ func (t *serializerImpl) serialize(input interface{}, encodingType common.Encodi
394395 switch encodingType {
395396 case common .EncodingTypeJSON , common .EncodingTypeUnknown , common .EncodingTypeEmpty : // For backward-compatibility
396397 encodingType = common .EncodingTypeJSON
398+ // input should never be a proto struct.
397399 data , err = json .Marshal (input )
398400 default :
399401 return nil , NewUnknownEncodingTypeError (encodingType )
@@ -406,30 +408,6 @@ func (t *serializerImpl) serialize(input interface{}, encodingType common.Encodi
406408 return NewDataBlob (data , encodingType ), nil
407409}
408410
409- func (t * serializerImpl ) deserialize (data * serialization.DataBlob , target interface {}) error {
410- if data == nil {
411- return nil
412- }
413- if len (data .Data ) == 0 {
414- return NewDeserializationError ("DeserializeEvent empty data" )
415- }
416- var err error
417-
418- switch data .GetEncoding () {
419- case common .EncodingTypeProto3 :
420- return NewDeserializationError (fmt .Sprintf ("proto requires proto specific deserialization" ))
421- case common .EncodingTypeJSON , common .EncodingTypeUnknown , common .EncodingTypeEmpty : // For backward-compatibility
422- err = json .Unmarshal (data .Data , target )
423- default :
424- return NewUnknownEncodingTypeError (data .GetEncoding ())
425- }
426-
427- if err != nil {
428- return NewDeserializationError (fmt .Sprintf ("DeserializeBatchEvents encoding: \" %v\" , error: %v" , data .Encoding , err .Error ()))
429- }
430- return nil
431- }
432-
433411// NewUnknownEncodingTypeError returns a new instance of encoding type error
434412func NewUnknownEncodingTypeError (encodingType common.EncodingType ) error {
435413 return & UnknownEncodingTypeError {encodingType : encodingType }
0 commit comments