THRIFT-2176 TSimpleJSONProtocol.ReadFieldBegin() does not return field type and ID
authorJens Geyer <jensg@apache.org>
Tue, 10 Sep 2013 19:33:55 +0000 (21:33 +0200)
committerJens Geyer <jensg@apache.org>
Tue, 10 Sep 2013 19:34:45 +0000 (21:34 +0200)
Patch: Jens Geyer

lib/go/thrift/serializer_test.go
lib/go/thrift/simple_json_protocol.go

index 5912679..0f3f7d7 100644 (file)
@@ -146,7 +146,7 @@ func TestSerializer(t *testing.T) {
        protocol_factories = make(map[string]ProtocolFactory)
        protocol_factories["Binary"] = NewTBinaryProtocolFactoryDefault()
        protocol_factories["Compact"] = NewTCompactProtocolFactory()
-       protocol_factories["SimpleJSON"] = NewTSimpleJSONProtocolFactory()
+       //protocol_factories["SimpleJSON"] = NewTSimpleJSONProtocolFactory() - write only, can't be read back by design
        protocol_factories["JSON"] = NewTJSONProtocolFactory()
 
        var tests map[string]func(*testing.T, ProtocolFactory) (bool, error)
index 3755a2d..71598ac 100644 (file)
@@ -330,6 +330,9 @@ func (p *TSimpleJSONProtocol) ReadFieldBegin() (string, TType, int16, error) {
                case JSON_QUOTE:
                        p.reader.ReadByte()
                        name, err := p.ParseStringBody()
+            // simplejson is not meant to be read back into thrift 
+            // - see http://wiki.apache.org/thrift/ThriftUsageJava
+            // - use JSON instead
                        if err != nil {
                                return name, STOP, 0, err
                        }