You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ns...@apache.org on 2016/01/02 18:59:03 UTC

[1/9] thrift git commit: THRIFT-3438 Enable py:new_style by default Client: Python Patch: Nobuaki Sukegawa

Repository: thrift
Updated Branches:
  refs/heads/master 6dde7f192 -> 269473d47


THRIFT-3438 Enable py:new_style by default
Client: Python
Patch: Nobuaki Sukegawa

This closes #759


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/b78d781b
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/b78d781b
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/b78d781b

Branch: refs/heads/master
Commit: b78d781b2e55a066d53577402e42b4d509998978
Parents: b9c859a
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Thu Dec 24 00:01:26 2015 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sat Jan 2 22:54:16 2016 +0900

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_py_generator.cc | 16 +++++++++++++---
 test/py/Makefile.am                         | 22 +++++++++++-----------
 test/py/RunClientServer.py                  |  2 +-
 3 files changed, 25 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/b78d781b/compiler/cpp/src/generate/t_py_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 81e4643..00be6e7 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -54,7 +54,16 @@ public:
     std::map<std::string, std::string>::const_iterator iter;
 
     iter = parsed_options.find("new_style");
-    gen_newstyle_ = (iter != parsed_options.end());
+    if (iter != parsed_options.end()) {
+      pwarning(0, "new_style is enabled by default, so the option will be removed in the near future.\n");
+    }
+
+    gen_newstyle_ = true;
+    iter = parsed_options.find("old_style");
+    if (iter != parsed_options.end()) {
+      gen_newstyle_ = false;
+      pwarning(0, "old_style is deprecated and may be removed in the future.\n");
+    }
 
     iter = parsed_options.find("slots");
     gen_slots_ = (iter != parsed_options.end());
@@ -63,7 +72,7 @@ public:
     gen_dynamic_ = (iter != parsed_options.end());
 
     if (gen_dynamic_) {
-      gen_newstyle_ = 0; // dynamic is newstyle
+      gen_newstyle_ = false; // dynamic is newstyle
       gen_dynbaseclass_ = "TBase";
       gen_dynbaseclass_frozen_ = "TFrozenBase";
       gen_dynbaseclass_exc_ = "TExceptionBase";
@@ -2574,7 +2583,8 @@ string t_py_generator::type_to_spec_args(t_type* ttype) {
 THRIFT_REGISTER_GENERATOR(
     py,
     "Python",
-    "    new_style:       Generate new-style classes.\n"
+    "    new_style:       No effect. Kept for backward compatibility.\n"
+    "    old_style:       Deprecated. Generate old-style classes.\n"
     "    twisted:         Generate Twisted-friendly RPC services.\n"
     "    tornado:         Generate code for use with Tornado.\n"
     "    utf8strings:     Encode/decode strings using utf8 in the generated code.\n"

http://git-wip-us.apache.org/repos/asf/thrift/blob/b78d781b/test/py/Makefile.am
----------------------------------------------------------------------
diff --git a/test/py/Makefile.am b/test/py/Makefile.am
index 1f710f1..d1d2278 100755
--- a/test/py/Makefile.am
+++ b/test/py/Makefile.am
@@ -29,10 +29,10 @@ thrift_gen =                                    \
         gen-py-default/DebugProtoTest/__init__.py \
         gen-py-slots/ThriftTest/__init__.py           \
         gen-py-slots/DebugProtoTest/__init__.py \
-        gen-py-newstyle/ThriftTest/__init__.py           \
-        gen-py-newstyle/DebugProtoTest/__init__.py \
-        gen-py-newstyleslots/ThriftTest/__init__.py           \
-        gen-py-newstyleslots/DebugProtoTest/__init__.py \
+        gen-py-oldstyle/ThriftTest/__init__.py \
+        gen-py-oldstyle/DebugProtoTest/__init__.py \
+        gen-py-oldstyleslots/ThriftTest/__init__.py \
+        gen-py-oldstyleslots/DebugProtoTest/__init__.py \
         gen-py-dynamic/ThriftTest/__init__.py           \
         gen-py-dynamic/DebugProtoTest/__init__.py \
         gen-py-dynamicslots/ThriftTest/__init__.py           \
@@ -64,13 +64,13 @@ gen-py-slots/%/__init__.py: ../%.thrift $(THRIFT)
 	test -d gen-py-slots || $(MKDIR_P) gen-py-slots
 	$(THRIFT) --gen py:slots -out gen-py-slots $<
 
-gen-py-newstyle/%/__init__.py: ../%.thrift $(THRIFT)
-	test -d gen-py-newstyle || $(MKDIR_P) gen-py-newstyle
-	$(THRIFT) --gen py:new_style -out gen-py-newstyle $<
+gen-py-oldstyle/%/__init__.py: ../%.thrift $(THRIFT)
+	test -d gen-py-oldstyle || $(MKDIR_P) gen-py-oldstyle
+	$(THRIFT) --gen py:old_style -out gen-py-oldstyle $<
 
-gen-py-newstyleslots/%/__init__.py: ../%.thrift $(THRIFT)
-	test -d gen-py-newstyleslots || $(MKDIR_P) gen-py-newstyleslots
-	$(THRIFT) --gen py:new_style,slots -out gen-py-newstyleslots $<
+gen-py-oldstyleslots/%/__init__.py: ../%.thrift $(THRIFT)
+	test -d gen-py-oldstyleslots || $(MKDIR_P) gen-py-oldstyleslots
+	$(THRIFT) --gen py:old_style,slots -out gen-py-oldstyleslots $<
 
 gen-py-dynamic/%/__init__.py: ../%.thrift $(THRIFT)
 	test -d gen-py-dynamic || $(MKDIR_P) gen-py-dynamic
@@ -81,4 +81,4 @@ gen-py-dynamicslots/%/__init__.py: ../%.thrift $(THRIFT)
 	$(THRIFT) --gen py:dynamic,slots -out gen-py-dynamicslots $<
 
 clean-local:
-	$(RM) -r gen-py gen-py-slots gen-py-default gen-py-newstyle gen-py-newstyleslots gen-py-dynamic gen-py-dynamicslots
+	$(RM) -r gen-py gen-py-slots gen-py-default gen-py-oldstyle gen-py-oldstyleslots gen-py-dynamic gen-py-dynamicslots

http://git-wip-us.apache.org/repos/asf/thrift/blob/b78d781b/test/py/RunClientServer.py
----------------------------------------------------------------------
diff --git a/test/py/RunClientServer.py b/test/py/RunClientServer.py
index f83f557..8a7ead5 100755
--- a/test/py/RunClientServer.py
+++ b/test/py/RunClientServer.py
@@ -250,7 +250,7 @@ def main():
   parser = OptionParser()
   parser.add_option('--all', action="store_true", dest='all')
   parser.add_option('--genpydirs', type='string', dest='genpydirs',
-                    default='default,slots,newstyle,newstyleslots,dynamic,dynamicslots',
+                    default='default,slots,oldstyle,dynamic,dynamicslots',
                     help='directory extensions for generated code, used as suffixes for \"gen-py-*\" added sys.path for individual tests')
   parser.add_option("--port", type="int", dest="port", default=9090,
                     help="port number for server to listen on")


[6/9] thrift git commit: THRIFT-3512 c_glib: Build fails due to missing features.h

Posted by ns...@apache.org.
THRIFT-3512 c_glib: Build fails due to missing features.h

This closes #763


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/56cf7795
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/56cf7795
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/56cf7795

Branch: refs/heads/master
Commit: 56cf779591b05cb68f83c8b71897dca7ec6d487c
Parents: 117af5c
Author: Simon South <si...@simonsouth.com>
Authored: Tue Dec 29 12:02:18 2015 -0500
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Jan 3 02:54:25 2016 +0900

----------------------------------------------------------------------
 lib/c_glib/test/testbinaryprotocol.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/56cf7795/lib/c_glib/test/testbinaryprotocol.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testbinaryprotocol.c b/lib/c_glib/test/testbinaryprotocol.c
index cd65501..fa1d447 100755
--- a/lib/c_glib/test/testbinaryprotocol.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -20,12 +20,8 @@
 /* Disable string-function optimizations when glibc is used, as these produce
    compiler warnings about string length when a string function is used inside
    a call to assert () */
-#if !defined(__APPLE__) && !defined(__FreeBSD__) && \
-    !defined(__OpenBSD__) && !defined(__NetBSD__)
-#include <features.h>
-#endif
-
 #ifdef __GLIBC__
+#include <features.h>
 #define __NO_STRING_INLINES 1
 #endif
 


[2/9] thrift git commit: THRIFT-3506 Eliminate old style classes from library code Client: Python Patch: Nobuaki Sukegawa

Posted by ns...@apache.org.
THRIFT-3506 Eliminate old style classes from library code
Client: Python
Patch: Nobuaki Sukegawa

This closes #758


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/b9c859a0
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/b9c859a0
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/b9c859a0

Branch: refs/heads/master
Commit: b9c859a07bae89643c0953a14e490cf3db435957
Parents: 7b89469
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Mon Dec 21 01:10:25 2015 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sat Jan 2 22:54:16 2016 +0900

----------------------------------------------------------------------
 lib/py/src/Thrift.py                    |  6 +++---
 lib/py/src/protocol/TBinaryProtocol.py  |  4 ++--
 lib/py/src/protocol/TCompactProtocol.py |  4 ++--
 lib/py/src/protocol/TJSONProtocol.py    |  2 +-
 lib/py/src/protocol/TProtocol.py        |  4 ++--
 lib/py/src/server/TNonblockingServer.py |  4 ++--
 lib/py/src/server/TServer.py            |  2 +-
 lib/py/src/transport/TTransport.py      | 12 ++++++------
 8 files changed, 19 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/Thrift.py
----------------------------------------------------------------------
diff --git a/lib/py/src/Thrift.py b/lib/py/src/Thrift.py
index cbb9184..11ee796 100644
--- a/lib/py/src/Thrift.py
+++ b/lib/py/src/Thrift.py
@@ -20,7 +20,7 @@
 import sys
 
 
-class TType:
+class TType(object):
   STOP   = 0
   VOID   = 1
   BOOL   = 2
@@ -59,14 +59,14 @@ class TType:
                      'UTF16')
 
 
-class TMessageType:
+class TMessageType(object):
   CALL = 1
   REPLY = 2
   EXCEPTION = 3
   ONEWAY = 4
 
 
-class TProcessor:
+class TProcessor(object):
   """Base class for procsessor, which works on two streams."""
 
   def process(iprot, oprot):

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/protocol/TBinaryProtocol.py
----------------------------------------------------------------------
diff --git a/lib/py/src/protocol/TBinaryProtocol.py b/lib/py/src/protocol/TBinaryProtocol.py
index f92f558..43cb5a4 100644
--- a/lib/py/src/protocol/TBinaryProtocol.py
+++ b/lib/py/src/protocol/TBinaryProtocol.py
@@ -223,7 +223,7 @@ class TBinaryProtocol(TProtocolBase):
     return s
 
 
-class TBinaryProtocolFactory:
+class TBinaryProtocolFactory(object):
   def __init__(self, strictRead=False, strictWrite=True):
     self.strictRead = strictRead
     self.strictWrite = strictWrite
@@ -255,6 +255,6 @@ class TBinaryProtocolAccelerated(TBinaryProtocol):
   pass
 
 
-class TBinaryProtocolAcceleratedFactory:
+class TBinaryProtocolAcceleratedFactory(object):
   def getProtocol(self, trans):
     return TBinaryProtocolAccelerated(trans)

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/protocol/TCompactProtocol.py
----------------------------------------------------------------------
diff --git a/lib/py/src/protocol/TCompactProtocol.py b/lib/py/src/protocol/TCompactProtocol.py
index b8d171e..a8b025a 100644
--- a/lib/py/src/protocol/TCompactProtocol.py
+++ b/lib/py/src/protocol/TCompactProtocol.py
@@ -79,7 +79,7 @@ def readVarint(trans):
     shift += 7
 
 
-class CompactType:
+class CompactType(object):
   STOP = 0x00
   TRUE = 0x01
   FALSE = 0x02
@@ -399,7 +399,7 @@ class TCompactProtocol(TProtocolBase):
     return TTYPES[byte & 0x0f]
 
 
-class TCompactProtocolFactory:
+class TCompactProtocolFactory(object):
   def __init__(self):
     pass
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/protocol/TJSONProtocol.py
----------------------------------------------------------------------
diff --git a/lib/py/src/protocol/TJSONProtocol.py b/lib/py/src/protocol/TJSONProtocol.py
index 3539412..acfce4a 100644
--- a/lib/py/src/protocol/TJSONProtocol.py
+++ b/lib/py/src/protocol/TJSONProtocol.py
@@ -559,7 +559,7 @@ class TJSONProtocol(TJSONProtocolBase):
     self.writeJSONBase64(binary)
 
 
-class TJSONProtocolFactory:
+class TJSONProtocolFactory(object):
 
   def getProtocol(self, trans):
     return TJSONProtocol(trans)

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/protocol/TProtocol.py
----------------------------------------------------------------------
diff --git a/lib/py/src/protocol/TProtocol.py b/lib/py/src/protocol/TProtocol.py
index 1d703e3..be2fcea 100644
--- a/lib/py/src/protocol/TProtocol.py
+++ b/lib/py/src/protocol/TProtocol.py
@@ -39,7 +39,7 @@ class TProtocolException(TException):
     self.type = type
 
 
-class TProtocolBase:
+class TProtocolBase(object):
   """Base class for Thrift protocol driver."""
 
   def __init__(self, trans):
@@ -445,6 +445,6 @@ def checkIntegerLimits(i, bits):
                                   "i64 requires -9223372036854775808 <= number <= 9223372036854775807")
 
 
-class TProtocolFactory:
+class TProtocolFactory(object):
   def getProtocol(self, trans):
     pass

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/server/TNonblockingServer.py
----------------------------------------------------------------------
diff --git a/lib/py/src/server/TNonblockingServer.py b/lib/py/src/server/TNonblockingServer.py
index 79748b7..a930a80 100644
--- a/lib/py/src/server/TNonblockingServer.py
+++ b/lib/py/src/server/TNonblockingServer.py
@@ -88,7 +88,7 @@ def socket_exception(func):
     return read
 
 
-class Connection:
+class Connection(object):
     """Basic class is represented connection.
 
     It can be in state:
@@ -222,7 +222,7 @@ class Connection:
         self.socket.close()
 
 
-class TNonblockingServer:
+class TNonblockingServer(object):
     """Non-blocking server."""
 
     def __init__(self,

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/server/TServer.py
----------------------------------------------------------------------
diff --git a/lib/py/src/server/TServer.py b/lib/py/src/server/TServer.py
index 130f730..30f063b 100644
--- a/lib/py/src/server/TServer.py
+++ b/lib/py/src/server/TServer.py
@@ -31,7 +31,7 @@ from thrift.protocol import TBinaryProtocol
 from thrift.transport import TTransport
 
 
-class TServer:
+class TServer(object):
   """Base interface for a server, which must have a serve() method.
 
   Three constructors for all servers:

http://git-wip-us.apache.org/repos/asf/thrift/blob/b9c859a0/lib/py/src/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/lib/py/src/transport/TTransport.py b/lib/py/src/transport/TTransport.py
index 92dc4cd..8e2da8d 100644
--- a/lib/py/src/transport/TTransport.py
+++ b/lib/py/src/transport/TTransport.py
@@ -36,7 +36,7 @@ class TTransportException(TException):
     self.type = type
 
 
-class TTransportBase:
+class TTransportBase(object):
   """Base class for Thrift transport layer."""
 
   def isOpen(self):
@@ -72,7 +72,7 @@ class TTransportBase:
 
 
 # This class should be thought of as an interface.
-class CReadableTransport:
+class CReadableTransport(object):
   """base class for transports that are readable from C"""
 
   # TODO(dreiss): Think about changing this interface to allow us to use
@@ -100,7 +100,7 @@ class CReadableTransport:
     pass
 
 
-class TServerTransportBase:
+class TServerTransportBase(object):
   """Base class for Thrift server transports."""
 
   def listen(self):
@@ -113,14 +113,14 @@ class TServerTransportBase:
     pass
 
 
-class TTransportFactoryBase:
+class TTransportFactoryBase(object):
   """Base class for a Transport Factory"""
 
   def getTransport(self, trans):
     return trans
 
 
-class TBufferedTransportFactory:
+class TBufferedTransportFactory(object):
   """Factory transport that builds buffered transports"""
 
   def getTransport(self, trans):
@@ -244,7 +244,7 @@ class TMemoryBuffer(TTransportBase, CReadableTransport):
     raise EOFError()
 
 
-class TFramedTransportFactory:
+class TFramedTransportFactory(object):
   """Factory transport that builds framed transports"""
 
   def getTransport(self, trans):


[3/9] thrift git commit: THRIFT-3504 Fix FastbinaryTest.py Client: Python Patch: Nobuaki Sukegawa

Posted by ns...@apache.org.
THRIFT-3504 Fix FastbinaryTest.py
Client: Python
Patch: Nobuaki Sukegawa

This closes #757


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/7b894694
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/7b894694
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/7b894694

Branch: refs/heads/master
Commit: 7b8946941e5bcb1217711115fed3f6c77d73b5ef
Parents: 6dde7f1
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Wed Dec 23 21:45:06 2015 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sat Jan 2 22:54:16 2016 +0900

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_py_generator.cc |   2 +-
 lib/py/src/protocol/fastbinary.c            |   5 +-
 lib/py/src/transport/TTransport.py          |   7 +-
 test/DebugProtoTest.thrift                  |  10 +-
 test/FastbinaryTest.py                      | 222 -----------------------
 test/Makefile.am                            |   1 -
 test/py/FastbinaryTest.py                   | 215 ++++++++++++++++++++++
 test/py/RunClientServer.py                  |   1 +
 8 files changed, 228 insertions(+), 235 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/compiler/cpp/src/generate/t_py_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_py_generator.cc b/compiler/cpp/src/generate/t_py_generator.cc
index 49c0b57..81e4643 100644
--- a/compiler/cpp/src/generate/t_py_generator.cc
+++ b/compiler/cpp/src/generate/t_py_generator.cc
@@ -2087,7 +2087,7 @@ void t_py_generator::generate_deserialize_container(ofstream& out, t_type* ttype
   // Declare variables, read header
   if (ttype->is_map()) {
     out << indent() << prefix << " = {}" << endl << indent() << "(" << ktype << ", " << vtype
-        << ", " << size << " ) = iprot.readMapBegin()" << endl;
+        << ", " << size << ") = iprot.readMapBegin()" << endl;
   } else if (ttype->is_set()) {
     out << indent() << prefix << " = set()" << endl << indent() << "(" << etype << ", " << size
         << ") = iprot.readSetBegin()" << endl;

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/lib/py/src/protocol/fastbinary.c
----------------------------------------------------------------------
diff --git a/lib/py/src/protocol/fastbinary.c b/lib/py/src/protocol/fastbinary.c
index a17019b..091a617 100644
--- a/lib/py/src/protocol/fastbinary.c
+++ b/lib/py/src/protocol/fastbinary.c
@@ -290,7 +290,7 @@ parse_struct_item_spec(StructItemSpec* dest, PyObject* spec_tuple) {
 
   // i'd like to use ParseArgs here, but it seems to be a bottleneck.
   if (PyTuple_Size(spec_tuple) != 5) {
-    PyErr_Format(PyExc_TypeError, "expecting 5 arguments for spec tuple but got %d", PyTuple_Size(spec_tuple));
+    PyErr_Format(PyExc_TypeError, "expecting 5 arguments for spec tuple but got %d", (int)PyTuple_Size(spec_tuple));
     return false;
   }
 
@@ -350,7 +350,7 @@ static void writeDouble(PyObject* outbuf, double dub) {
 
 /* --- MAIN RECURSIVE OUTPUT FUNCTION -- */
 
-static int
+static bool
 output_val(PyObject* output, PyObject* value, TType type, PyObject* typeargs) {
   /*
    * Refcounting Strategy:
@@ -1185,7 +1185,6 @@ decode_val(DecodeBuffer* input, TType type, PyObject* typeargs) {
 
   case T_STRUCT: {
     StructTypeArgs parsedargs;
-    PyObject* ret;
     if (!parse_struct_args(&parsedargs, typeargs)) {
       return NULL;
     }

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/lib/py/src/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/lib/py/src/transport/TTransport.py b/lib/py/src/transport/TTransport.py
index 3fe289a..92dc4cd 100644
--- a/lib/py/src/transport/TTransport.py
+++ b/lib/py/src/transport/TTransport.py
@@ -139,7 +139,8 @@ class TBufferedTransport(TTransportBase, CReadableTransport):
   def __init__(self, trans, rbuf_size=DEFAULT_BUFFER):
     self.__trans = trans
     self.__wbuf = BufferIO()
-    self.__rbuf = BufferIO()
+    # Pass string argument to initialize read buffer as cStringIO.InputType
+    self.__rbuf = BufferIO(b'')
     self.__rbuf_size = rbuf_size
 
   def isOpen(self):
@@ -256,7 +257,7 @@ class TFramedTransport(TTransportBase, CReadableTransport):
 
   def __init__(self, trans,):
     self.__trans = trans
-    self.__rbuf = BufferIO()
+    self.__rbuf = BufferIO(b'')
     self.__wbuf = BufferIO()
 
   def isOpen(self):
@@ -364,7 +365,7 @@ class TSaslClientTransport(TTransportBase, CReadableTransport):
     self.sasl = SASLClient(host, service, mechanism, **sasl_kwargs)
 
     self.__wbuf = BufferIO()
-    self.__rbuf = BufferIO()
+    self.__rbuf = BufferIO(b'')
 
   def open(self):
     if not self.transport.isOpen():

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/test/DebugProtoTest.thrift
----------------------------------------------------------------------
diff --git a/test/DebugProtoTest.thrift b/test/DebugProtoTest.thrift
index e7119c4..9726d00 100644
--- a/test/DebugProtoTest.thrift
+++ b/test/DebugProtoTest.thrift
@@ -62,7 +62,7 @@ struct Nesting {
 
 struct HolyMoley {
   1: list<OneOfEach> big,
-  2: set<list<string>> contain,
+  2: set<list<string> (python.immutable = "")> contain,
   3: map<string,list<Bonk>> bonks,
 }
 
@@ -259,10 +259,10 @@ service EmptyService {}
 // The only purpose of this thing is to increase the size of the generated code
 // so that ZlibTest has more highly compressible data to play with.
 struct BlowUp {
-  1: map<list<i32>,set<map<i32,string>>> b1;
-  2: map<list<i32>,set<map<i32,string>>> b2;
-  3: map<list<i32>,set<map<i32,string>>> b3;
-  4: map<list<i32>,set<map<i32,string>>> b4;
+  1: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b1;
+  2: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b2;
+  3: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b3;
+  4: map<list<i32>(python.immutable = ""),set<map<i32,string> (python.immutable = "")>> b4;
 }
 
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/test/FastbinaryTest.py
----------------------------------------------------------------------
diff --git a/test/FastbinaryTest.py b/test/FastbinaryTest.py
deleted file mode 100755
index 7f6efae..0000000
--- a/test/FastbinaryTest.py
+++ /dev/null
@@ -1,222 +0,0 @@
-#!/usr/bin/env python
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-r"""
-thrift --gen py DebugProtoTest.thrift
-./FastbinaryTest.py
-"""
-
-# TODO(dreiss): Test error cases.  Check for memory leaks.
-
-import sys
-sys.path.append('./gen-py')
-
-import math
-from DebugProtoTest import Srv
-from DebugProtoTest.ttypes import *
-from thrift.transport import TTransport
-from thrift.protocol import TBinaryProtocol
-
-import timeit
-from cStringIO import StringIO
-from copy import deepcopy
-from pprint import pprint
-
-class TDevNullTransport(TTransport.TTransportBase):
-  def __init__(self):
-    pass
-  def isOpen(self):
-    return True
-
-ooe1 = OneOfEach()
-ooe1.im_true   = True;
-ooe1.im_false  = False;
-ooe1.a_bite    = 0xd6;
-ooe1.integer16 = 27000;
-ooe1.integer32 = 1<<24;
-ooe1.integer64 = 6000 * 1000 * 1000;
-ooe1.double_precision = math.pi;
-ooe1.some_characters  = "Debug THIS!";
-ooe1.zomg_unicode     = "\xd7\n\a\t";
-
-ooe2 = OneOfEach();
-ooe2.integer16 = 16;
-ooe2.integer32 = 32;
-ooe2.integer64 = 64;
-ooe2.double_precision = (math.sqrt(5)+1)/2;
-ooe2.some_characters  = ":R (me going \"rrrr\")";
-ooe2.zomg_unicode     = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"\
-                        "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe"\
-                        "\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"\
-                        "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba"\
-                        "\xc7\x83\xe2\x80\xbc";
-
-hm = HolyMoley({"big":[], "contain":set(), "bonks":{}})
-hm.big.append(ooe1)
-hm.big.append(ooe2)
-hm.big[0].a_bite = 0x22;
-hm.big[1].a_bite = 0x22;
-
-hm.contain.add(("and a one", "and a two"))
-hm.contain.add(("then a one, two", "three!", "FOUR!"))
-hm.contain.add(())
-
-hm.bonks["nothing"] = [];
-hm.bonks["something"] = [
-  Bonk({"type":1, "message":"Wait."}),
-  Bonk({"type":2, "message":"What?"}),
-]
-hm.bonks["poe"] = [
-  Bonk({"type":3, "message":"quoth"}),
-  Bonk({"type":4, "message":"the raven"}),
-  Bonk({"type":5, "message":"nevermore"}),
-]
-
-rs = RandomStuff()
-rs.a = 1
-rs.b = 2
-rs.c = 3
-rs.myintlist = range(20)
-rs.maps = {1:Wrapper({"foo":Empty()}),2:Wrapper({"foo":Empty()})}
-rs.bigint = 124523452435L
-rs.triple = 3.14
-
-# make sure this splits two buffers in a buffered protocol
-rshuge = RandomStuff()
-rshuge.myintlist=range(10000)
-
-my_zero = Srv.Janky_result({"arg":5})
-
-def checkWrite(o):
-  trans_fast = TTransport.TMemoryBuffer()
-  trans_slow = TTransport.TMemoryBuffer()
-  prot_fast = TBinaryProtocol.TBinaryProtocolAccelerated(trans_fast)
-  prot_slow = TBinaryProtocol.TBinaryProtocol(trans_slow)
-
-  o.write(prot_fast)
-  o.write(prot_slow)
-  ORIG = trans_slow.getvalue()
-  MINE = trans_fast.getvalue()
-  if ORIG != MINE:
-    print "mine: %s\norig: %s" % (repr(MINE), repr(ORIG))
-
-def checkRead(o):
-  prot = TBinaryProtocol.TBinaryProtocol(TTransport.TMemoryBuffer())
-  o.write(prot)
-
-  slow_version_binary = prot.trans.getvalue()
-
-  prot = TBinaryProtocol.TBinaryProtocolAccelerated(
-           TTransport.TMemoryBuffer(slow_version_binary))
-  c = o.__class__()
-  c.read(prot)
-  if c != o:
-    print "copy: "
-    pprint(eval(repr(c)))
-    print "orig: "
-    pprint(eval(repr(o)))
-
-  prot = TBinaryProtocol.TBinaryProtocolAccelerated(
-           TTransport.TBufferedTransport(
-             TTransport.TMemoryBuffer(slow_version_binary)))
-  c = o.__class__()
-  c.read(prot)
-  if c != o:
-    print "copy: "
-    pprint(eval(repr(c)))
-    print "orig: "
-    pprint(eval(repr(o)))
-
-
-def doTest():
-  checkWrite(hm)
-  no_set = deepcopy(hm)
-  no_set.contain = set()
-  checkRead(no_set)
-  checkWrite(rs)
-  checkRead(rs)
-  checkWrite(rshuge)
-  checkRead(rshuge)
-  checkWrite(my_zero)
-  checkRead(my_zero)
-  checkRead(Backwards({"first_tag2":4, "second_tag1":2}))
-
-  # One case where the serialized form changes, but only superficially.
-  o = Backwards({"first_tag2":4, "second_tag1":2})
-  trans_fast = TTransport.TMemoryBuffer()
-  trans_slow = TTransport.TMemoryBuffer()
-  prot_fast = TBinaryProtocol.TBinaryProtocolAccelerated(trans_fast)
-  prot_slow = TBinaryProtocol.TBinaryProtocol(trans_slow)
-
-  o.write(prot_fast)
-  o.write(prot_slow)
-  ORIG = trans_slow.getvalue()
-  MINE = trans_fast.getvalue()
-  if ORIG == MINE:
-    print "That shouldn't happen."
-
-
-  prot = TBinaryProtocol.TBinaryProtocolAccelerated(TTransport.TMemoryBuffer())
-  o.write(prot)
-  prot = TBinaryProtocol.TBinaryProtocol(
-           TTransport.TMemoryBuffer(
-             prot.trans.getvalue()))
-  c = o.__class__()
-  c.read(prot)
-  if c != o:
-    print "copy: "
-    pprint(eval(repr(c)))
-    print "orig: "
-    pprint(eval(repr(o)))
-
-
-
-def doBenchmark():
-
-  iters = 25000
-
-  setup = """
-from __main__ import hm, rs, TDevNullTransport
-from thrift.protocol import TBinaryProtocol
-trans = TDevNullTransport()
-prot = TBinaryProtocol.TBinaryProtocol%s(trans)
-"""
-
-  setup_fast = setup % "Accelerated"
-  setup_slow = setup % ""
-
-  print "Starting Benchmarks"
-
-  print "HolyMoley Standard = %f" % \
-      timeit.Timer('hm.write(prot)', setup_slow).timeit(number=iters)
-  print "HolyMoley Acceler. = %f" % \
-      timeit.Timer('hm.write(prot)', setup_fast).timeit(number=iters)
-
-  print "FastStruct Standard = %f" % \
-      timeit.Timer('rs.write(prot)', setup_slow).timeit(number=iters)
-  print "FastStruct Acceler. = %f" % \
-      timeit.Timer('rs.write(prot)', setup_fast).timeit(number=iters)
-
-
-
-doTest()
-doBenchmark()
-

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/test/Makefile.am
----------------------------------------------------------------------
diff --git a/test/Makefile.am b/test/Makefile.am
index 593b1c4..c1fd589 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -124,7 +124,6 @@ EXTRA_DIST = \
 	tests.json \
 	ThriftTest.thrift \
 	TypedefTest.thrift \
-	FastbinaryTest.py \
 	result.html \
 	README.md \
 	valgrind.suppress

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/test/py/FastbinaryTest.py
----------------------------------------------------------------------
diff --git a/test/py/FastbinaryTest.py b/test/py/FastbinaryTest.py
new file mode 100755
index 0000000..0583373
--- /dev/null
+++ b/test/py/FastbinaryTest.py
@@ -0,0 +1,215 @@
+#!/usr/bin/env python
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+r"""
+PYTHONPATH=./gen-py:../../lib/py/build/lib... ./FastbinaryTest.py
+"""
+
+# TODO(dreiss): Test error cases.  Check for memory leaks.
+
+import math
+import timeit
+
+from copy import deepcopy
+from pprint import pprint
+
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol
+
+from DebugProtoTest import Srv
+from DebugProtoTest.ttypes import Backwards, Bonk, Empty, HolyMoley, OneOfEach, RandomStuff, Wrapper
+
+
+class TDevNullTransport(TTransport.TTransportBase):
+  def __init__(self):
+    pass
+
+  def isOpen(self):
+    return True
+
+ooe1 = OneOfEach()
+ooe1.im_true = True
+ooe1.im_false = False
+ooe1.a_bite = 0xd6
+ooe1.integer16 = 27000
+ooe1.integer32 = 1 << 24
+ooe1.integer64 = 6000 * 1000 * 1000
+ooe1.double_precision = math.pi
+ooe1.some_characters = "Debug THIS!"
+ooe1.zomg_unicode = "\xd7\n\a\t"
+
+ooe2 = OneOfEach()
+ooe2.integer16 = 16
+ooe2.integer32 = 32
+ooe2.integer64 = 64
+ooe2.double_precision = (math.sqrt(5) + 1) / 2
+ooe2.some_characters = ":R (me going \"rrrr\")"
+ooe2.zomg_unicode = "\xd3\x80\xe2\x85\xae\xce\x9d\x20"\
+                    "\xd0\x9d\xce\xbf\xe2\x85\xbf\xd0\xbe"\
+                    "\xc9\xa1\xd0\xb3\xd0\xb0\xcf\x81\xe2\x84\x8e"\
+                    "\x20\xce\x91\x74\x74\xce\xb1\xe2\x85\xbd\xce\xba"\
+                    "\xc7\x83\xe2\x80\xbc"
+
+hm = HolyMoley(**{"big": [], "contain": set(), "bonks": {}})
+hm.big.append(ooe1)
+hm.big.append(ooe2)
+hm.big[0].a_bite = 0x22
+hm.big[1].a_bite = 0x22
+
+hm.contain.add(("and a one", "and a two"))
+hm.contain.add(("then a one, two", "three!", "FOUR!"))
+hm.contain.add(())
+
+hm.bonks["nothing"] = []
+hm.bonks["something"] = [
+  Bonk(**{"type": 1, "message": "Wait."}),
+  Bonk(**{"type": 2, "message": "What?"}),
+]
+hm.bonks["poe"] = [
+  Bonk(**{"type": 3, "message": "quoth"}),
+  Bonk(**{"type": 4, "message": "the raven"}),
+  Bonk(**{"type": 5, "message": "nevermore"}),
+]
+
+rs = RandomStuff()
+rs.a = 1
+rs.b = 2
+rs.c = 3
+rs.myintlist = range(20)
+rs.maps = {1: Wrapper(**{"foo": Empty()}), 2: Wrapper(**{"foo": Empty()})}
+rs.bigint = 124523452435
+rs.triple = 3.14
+
+# make sure this splits two buffers in a buffered protocol
+rshuge = RandomStuff()
+rshuge.myintlist = range(10000)
+
+my_zero = Srv.Janky_result(**{"success": 5})
+
+
+def check_write(o):
+  trans_fast = TTransport.TMemoryBuffer()
+  trans_slow = TTransport.TMemoryBuffer()
+  prot_fast = TBinaryProtocol.TBinaryProtocolAccelerated(trans_fast)
+  prot_slow = TBinaryProtocol.TBinaryProtocol(trans_slow)
+
+  o.write(prot_fast)
+  o.write(prot_slow)
+  ORIG = trans_slow.getvalue()
+  MINE = trans_fast.getvalue()
+  if ORIG != MINE:
+    print("mine: %s\norig: %s" % (repr(MINE), repr(ORIG)))
+
+
+def check_read(o):
+  prot = TBinaryProtocol.TBinaryProtocol(TTransport.TMemoryBuffer())
+  o.write(prot)
+
+  slow_version_binary = prot.trans.getvalue()
+
+  prot = TBinaryProtocol.TBinaryProtocolAccelerated(
+      TTransport.TMemoryBuffer(slow_version_binary))
+  c = o.__class__()
+  c.read(prot)
+  if c != o:
+    print("copy: ")
+    pprint(eval(repr(c)))
+    print("orig: ")
+    pprint(eval(repr(o)))
+
+  prot = TBinaryProtocol.TBinaryProtocolAccelerated(
+      TTransport.TBufferedTransport(
+        TTransport.TMemoryBuffer(slow_version_binary)))
+  c = o.__class__()
+  c.read(prot)
+  if c != o:
+    print("copy: ")
+    pprint(eval(repr(c)))
+    print("orig: ")
+    pprint(eval(repr(o)))
+
+
+def do_test():
+  check_write(hm)
+  check_read(HolyMoley())
+  no_set = deepcopy(hm)
+  no_set.contain = set()
+  check_read(no_set)
+  check_write(rs)
+  check_read(rs)
+  check_write(rshuge)
+  check_read(rshuge)
+  check_write(my_zero)
+  check_read(my_zero)
+  check_read(Backwards(**{"first_tag2": 4, "second_tag1": 2}))
+
+  # One case where the serialized form changes, but only superficially.
+  o = Backwards(**{"first_tag2": 4, "second_tag1": 2})
+  trans_fast = TTransport.TMemoryBuffer()
+  trans_slow = TTransport.TMemoryBuffer()
+  prot_fast = TBinaryProtocol.TBinaryProtocolAccelerated(trans_fast)
+  prot_slow = TBinaryProtocol.TBinaryProtocol(trans_slow)
+
+  o.write(prot_fast)
+  o.write(prot_slow)
+  ORIG = trans_slow.getvalue()
+  MINE = trans_fast.getvalue()
+  assert id(ORIG) != id(MINE)
+
+  prot = TBinaryProtocol.TBinaryProtocolAccelerated(TTransport.TMemoryBuffer())
+  o.write(prot)
+  prot = TBinaryProtocol.TBinaryProtocol(
+      TTransport.TMemoryBuffer(prot.trans.getvalue()))
+  c = o.__class__()
+  c.read(prot)
+  if c != o:
+    print("copy: ")
+    pprint(eval(repr(c)))
+    print("orig: ")
+    pprint(eval(repr(o)))
+
+
+def do_benchmark(iters=5000):
+  setup = """
+from __main__ import hm, rs, TDevNullTransport
+from thrift.protocol import TBinaryProtocol
+trans = TDevNullTransport()
+prot = TBinaryProtocol.TBinaryProtocol%s(trans)
+"""
+
+  setup_fast = setup % "Accelerated"
+  setup_slow = setup % ""
+
+  print("Starting Benchmarks")
+
+  print("HolyMoley Standard = %f" %
+        timeit.Timer('hm.write(prot)', setup_slow).timeit(number=iters))
+  print("HolyMoley Acceler. = %f" %
+        timeit.Timer('hm.write(prot)', setup_fast).timeit(number=iters))
+
+  print("FastStruct Standard = %f" %
+        timeit.Timer('rs.write(prot)', setup_slow).timeit(number=iters))
+  print("FastStruct Acceler. = %f" %
+        timeit.Timer('rs.write(prot)', setup_fast).timeit(number=iters))
+
+if __name__ == '__main__':
+  do_test()
+  do_benchmark()

http://git-wip-us.apache.org/repos/asf/thrift/blob/7b894694/test/py/RunClientServer.py
----------------------------------------------------------------------
diff --git a/test/py/RunClientServer.py b/test/py/RunClientServer.py
index f084a41..f83f557 100755
--- a/test/py/RunClientServer.py
+++ b/test/py/RunClientServer.py
@@ -37,6 +37,7 @@ DEFAULT_LIBDIR_GLOB = os.path.join(ROOT_DIR, 'lib', 'py', 'build', 'lib.*')
 DEFAULT_LIBDIR_PY3 = os.path.join(ROOT_DIR, 'lib', 'py', 'build', 'lib')
 
 SCRIPTS = [
+  'FastbinaryTest.py',
   'TestFrozen.py',
   'TSimpleJSONProtocolTest.py',
   'SerializationTest.py',


[5/9] thrift git commit: THRIFT-3498 C++ library assumes optional function pthread_attr_setschedpolicy is available Client: C++ Patch: Simon South

Posted by ns...@apache.org.
THRIFT-3498 C++ library assumes optional function pthread_attr_setschedpolicy is available
Client: C++
Patch: Simon South

PosixThreadFactory.cpp: Test for availability of optional
pthread_attr_setschedpolicy function before including in source code

This closes #754


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/117af5c3
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/117af5c3
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/117af5c3

Branch: refs/heads/master
Commit: 117af5c3a3216c1bb21a38d395032c2016116300
Parents: ad83586
Author: Simon South <si...@simonsouth.com>
Authored: Mon Dec 21 14:01:36 2015 -0500
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Jan 3 02:40:38 2016 +0900

----------------------------------------------------------------------
 lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/117af5c3/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
index 47c5034..05a3c02 100644
--- a/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
+++ b/lib/cpp/src/thrift/concurrency/PosixThreadFactory.cpp
@@ -124,9 +124,11 @@ public:
     policy_ = PosixThreadFactory::OTHER;
 #endif
 
+#if _POSIX_THREAD_PRIORITY_SCHEDULING > 0
     if (pthread_attr_setschedpolicy(&thread_attr, policy_) != 0) {
       throw SystemResourceException("pthread_attr_setschedpolicy failed");
     }
+#endif
 
     struct sched_param sched_param;
     sched_param.sched_priority = priority_;


[7/9] thrift git commit: THRIFT-3383 i64 related warnings

Posted by ns...@apache.org.
THRIFT-3383 i64 related warnings

This closes #764


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/bf8f7b42
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/bf8f7b42
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/bf8f7b42

Branch: refs/heads/master
Commit: bf8f7b425ee24269ae71c5431362d17a5ca475ef
Parents: 56cf779
Author: Simon South <si...@simonsouth.com>
Authored: Wed Dec 23 20:29:29 2015 -0500
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Jan 3 02:55:03 2016 +0900

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_c_glib_generator.cc |  4 +-
 lib/c_glib/test/testbinaryprotocol.c            |  2 +-
 lib/c_glib/test/testdebugproto.c                | 44 +++++----
 lib/c_glib/test/testoptionalrequired.c          |  2 +-
 lib/c_glib/test/testserialization.c             | 18 ++--
 lib/c_glib/test/testthrifttestclient.cpp        | 97 ++++++++++----------
 6 files changed, 90 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/bf8f7b42/compiler/cpp/src/generate/t_c_glib_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_c_glib_generator.cc b/compiler/cpp/src/generate/t_c_glib_generator.cc
index 22d7914..0eefeb6 100644
--- a/compiler/cpp/src/generate/t_c_glib_generator.cc
+++ b/compiler/cpp/src/generate/t_c_glib_generator.cc
@@ -808,9 +808,11 @@ string t_c_glib_generator::constant_value(string name, t_type* type, t_const_val
     case t_base_type::TYPE_I8:
     case t_base_type::TYPE_I16:
     case t_base_type::TYPE_I32:
-    case t_base_type::TYPE_I64:
       render << value->get_integer();
       break;
+    case t_base_type::TYPE_I64:
+      render << "G_GINT64_CONSTANT (" << value->get_integer() << ")";
+      break;
     case t_base_type::TYPE_DOUBLE:
       if (value->get_type() == t_const_value::CV_INTEGER) {
         render << value->get_integer();

http://git-wip-us.apache.org/repos/asf/thrift/blob/bf8f7b42/lib/c_glib/test/testbinaryprotocol.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testbinaryprotocol.c b/lib/c_glib/test/testbinaryprotocol.c
index fa1d447..96b2019 100755
--- a/lib/c_glib/test/testbinaryprotocol.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -41,7 +41,7 @@
 #define TEST_BYTE 123
 #define TEST_I16 12345
 #define TEST_I32 1234567890
-#define TEST_I64 123456789012345
+#define TEST_I64 G_GINT64_CONSTANT (123456789012345)
 #define TEST_DOUBLE 1234567890.123
 #define TEST_STRING "this is a test string 1234567890!@#$%^&*()"
 #define TEST_PORT 51199

http://git-wip-us.apache.org/repos/asf/thrift/blob/bf8f7b42/lib/c_glib/test/testdebugproto.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testdebugproto.c b/lib/c_glib/test/testdebugproto.c
index 703dff0..47ac588 100644
--- a/lib/c_glib/test/testdebugproto.c
+++ b/lib/c_glib/test/testdebugproto.c
@@ -146,7 +146,7 @@ test_structs_one_of_each_initialize_default_values (void)
 
   g_assert_cmpint (a_bite,    ==, 0x7f);
   g_assert_cmpint (integer16, ==, 0x7fff);
-  g_assert_cmpint (integer64, ==, 10000000000);
+  g_assert_cmpint (integer64, ==, G_GINT64_CONSTANT (10000000000));
 
   g_assert (byte_list != NULL);
   g_assert_cmpint (byte_list->len, ==, 3);
@@ -179,8 +179,11 @@ test_structs_one_of_each_initialize_specified_values (void)
   static const gint16 initial_i16_list[5] = { 4181, 6765, 10946, 17711, 28657 };
   static const gint64 initial_i64_list[5] =
     {
-      1100087778366101931, 1779979416004714189, 2880067194370816120,
-      4660046610375530309, 7540113804746346429
+      G_GINT64_CONSTANT (1100087778366101931),
+      G_GINT64_CONSTANT (1779979416004714189),
+      G_GINT64_CONSTANT (2880067194370816120),
+      G_GINT64_CONSTANT (4660046610375530309),
+      G_GINT64_CONSTANT (7540113804746346429)
     };
   static const guint8 initial_base64[8] =
     {
@@ -216,22 +219,23 @@ test_structs_one_of_each_initialize_specified_values (void)
   g_array_append_vals (i64_list, initial_i64_list, 5);
 
   /* All of OneOfEach's properties can be set at construction... */
-  one_of_each = g_object_new (T_TEST_TYPE_ONE_OF_EACH,
-                              "im_true",          TRUE,
-                              "im_false",         FALSE,
-                              "a_bite",           0x50,
-                              "integer16",        0x7e57,
-                              "integer32",        0xdeadbeef,
-                              "integer64",        0xfa15efacade15bad,
-                              "double_precision", M_PI,
-                              "some_characters",  "Debug THIS!",
-                              "zomg_unicode",     "\xd7\n\a\t",
-                              "what_who",         TRUE,
-                              "base64",           base64,
-                              "byte_list",        byte_list,
-                              "i16_list",         i16_list,
-                              "i64_list",         i64_list,
-                              NULL);
+  one_of_each =
+    g_object_new (T_TEST_TYPE_ONE_OF_EACH,
+                  "im_true",          TRUE,
+                  "im_false",         FALSE,
+                  "a_bite",           0x50,
+                  "integer16",        0x7e57,
+                  "integer32",        0xdeadbeef,
+                  "integer64",        G_GINT64_CONSTANT (0xfa15efacade15bad),
+                  "double_precision", M_PI,
+                  "some_characters",  "Debug THIS!",
+                  "zomg_unicode",     "\xd7\n\a\t",
+                  "what_who",         TRUE,
+                  "base64",           base64,
+                  "byte_list",        byte_list,
+                  "i16_list",         i16_list,
+                  "i64_list",         i64_list,
+                  NULL);
   g_assert (one_of_each != NULL);
 
   g_array_unref (i64_list);
@@ -267,7 +271,7 @@ test_structs_one_of_each_initialize_specified_values (void)
   g_assert_cmphex (a_bite,    ==, 0x50);
   g_assert_cmphex (integer16, ==, 0x7e57);
   g_assert_cmphex (integer32, ==, (gint32)0xdeadbeef);
-  g_assert_cmphex (integer64, ==, 0xfa15efacade15bad);
+  g_assert_cmphex (integer64, ==, G_GINT64_CONSTANT (0xfa15efacade15bad));
 
   g_assert_cmpfloat (double_precision, ==, M_PI);
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/bf8f7b42/lib/c_glib/test/testoptionalrequired.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testoptionalrequired.c b/lib/c_glib/test/testoptionalrequired.c
index cfc96a2..60d8afd 100755
--- a/lib/c_glib/test/testoptionalrequired.c
+++ b/lib/c_glib/test/testoptionalrequired.c
@@ -201,7 +201,7 @@ test_non_set_binary (void)
   g_assert(!error);
   write_to_read (THRIFT_STRUCT (b2), THRIFT_STRUCT (b1), NULL, &error);
   g_assert(!error);
-  // OK. No segfault
+  /* OK. No segfault */
 
   g_object_unref (b1);
   g_object_unref (b2);

http://git-wip-us.apache.org/repos/asf/thrift/blob/bf8f7b42/lib/c_glib/test/testserialization.c
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testserialization.c b/lib/c_glib/test/testserialization.c
index 9fc6357..67d411d 100644
--- a/lib/c_glib/test/testserialization.c
+++ b/lib/c_glib/test/testserialization.c
@@ -14,12 +14,14 @@ static void enum_constants_read_write() {
   TTestEnumTestStruct* src = T_TEST_ENUM_TEST;
   TTestEnumTestStruct* dst = g_object_new(T_TEST_TYPE_ENUM_TEST_STRUCT, NULL);
   TTestEnumTestStructClass* cls = T_TEST_ENUM_TEST_STRUCT_GET_CLASS(src);
+  int write_len;
+  int read_len;
 
-  int write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
+  write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
   g_assert(!error);
   g_assert(write_len > 0);
 
-  int read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
+  read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
   g_assert(!error);
   g_assert_cmpint(write_len, ==, read_len);
 
@@ -37,12 +39,14 @@ static void struct_constants_read_write() {
   TTestCompactProtoTestStruct* src = T_TEST_COMPACT_TEST;
   TTestCompactProtoTestStruct* dst = g_object_new(T_TEST_TYPE_COMPACT_PROTO_TEST_STRUCT, NULL);
   TTestCompactProtoTestStructClass* cls = T_TEST_COMPACT_PROTO_TEST_STRUCT_GET_CLASS(src);
+  int write_len;
+  int read_len;
 
-  int write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
+  write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
   g_assert(!error);
   g_assert(write_len > 0);
 
-  int read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
+  read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
   g_assert(!error);
   g_assert_cmpint(write_len, ==, read_len);
 
@@ -60,12 +64,14 @@ static void struct_read_write_length_should_equal() {
   TTestBonk* src = g_object_new(T_TEST_TYPE_BONK, NULL);
   TTestBonk* dst = g_object_new(T_TEST_TYPE_BONK, NULL);
   TTestBonkClass* cls = T_TEST_BONK_GET_CLASS(src);
+  int write_len;
+  int read_len;
 
-  int write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
+  write_len = THRIFT_STRUCT_CLASS(cls)->write(THRIFT_STRUCT(src), protocol, &error);
   g_assert(!error);
   g_assert(write_len > 0);
 
-  int read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
+  read_len = THRIFT_STRUCT_CLASS(cls)->read(THRIFT_STRUCT(dst), protocol, &error);
   g_assert(!error);
   g_assert_cmpint(write_len, ==, read_len);
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/bf8f7b42/lib/c_glib/test/testthrifttestclient.cpp
----------------------------------------------------------------------
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index e618fe9..7681cf5 100755
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -59,128 +59,130 @@ class TestHandler : public ThriftTestIf {
   TestHandler() {}
 
   void testVoid() {
-    printf("[C -> C++] testVoid()\n");
+    cout << "[C -> C++] testVoid()" << endl;
   }
 
   void testString(string& out, const string &thing) {
-    printf("[C -> C++] testString(\"%s\")\n", thing.c_str());
+    cout << "[C -> C++] testString(\"" << thing << "\")" << endl;
     out = thing;
   }
 
   bool testBool(const bool thing) {
-    printf("[C -> C++] testBool(%s)\n", thing ? "true" : "false");
+    cout << "[C -> C++] testBool(" << (thing ? "true" : "false") << ")" << endl;
     return thing;
   }
   int8_t testByte(const int8_t thing) {
-    printf("[C -> C++] testByte(%d)\n", (int)thing);
+    cout << "[C -> C++] testByte(" << (int)thing << ")" << endl;
     return thing;
   }
   int32_t testI32(const int32_t thing) {
-    printf("[C -> C++] testI32(%d)\n", thing);
+    cout << "[C -> C++] testI32(" << thing << ")" << endl;
     return thing;
   }
 
   int64_t testI64(const int64_t thing) {
-    printf("[C -> C++] testI64(%ld)\n", thing);
+    cout << "[C -> C++] testI64(" << thing << ")" << endl;
     return thing;
   }
 
   double testDouble(const double thing) {
-    printf("[C -> C++] testDouble(%lf)\n", thing);
+    cout.precision(6);
+    cout << "[C -> C++] testDouble(" << fixed << thing << ")" << endl;
     return thing;
   }
 
   void testBinary(string& out, const string &thing) {
-    printf("[C -> C++] testBinary(\"%s\")\n", thing.c_str());
+    cout << "[C -> C++] testBinary(\"" << thing << "\")" << endl;
     out = thing;
   }
 
   void testStruct(Xtruct& out, const Xtruct &thing) {
-    printf("[C -> C++] testStruct({\"%s\", %d, %d, %ld})\n", thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing);
+    cout << "[C -> C++] testStruct({\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "})" << endl;
     out = thing;
   }
 
   void testNest(Xtruct2& out, const Xtruct2& nest) {
     const Xtruct &thing = nest.struct_thing;
-    printf("[C -> C++] testNest({%d, {\"%s\", %d, %d, %ld}, %d})\n", (int)nest.byte_thing, thing.string_thing.c_str(), (int)thing.byte_thing, thing.i32_thing, thing.i64_thing, nest.i32_thing);
+    cout << "[C -> C++] testNest({" << (int)nest.byte_thing << ", {\"" << thing.string_thing << "\", " << (int)thing.byte_thing << ", " << thing.i32_thing << ", " << thing.i64_thing << "}, " << nest.i32_thing << "})" << endl;
     out = nest;
   }
 
   void testMap(map<int32_t, int32_t> &out, const map<int32_t, int32_t> &thing) {
-    printf("[C -> C++] testMap({");
+    cout << "[C -> C++] testMap({";
     map<int32_t, int32_t>::const_iterator m_iter;
     bool first = true;
     for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
       if (first) {
         first = false;
       } else {
-        printf(", ");
+        cout << ", ";
       }
-      printf("%d => %d", m_iter->first, m_iter->second);
+      cout << m_iter->first << " => " << m_iter->second;
     }
-    printf("})\n");
+    cout << "})" << endl;
     out = thing;
   }
 
   void testStringMap(map<std::string, std::string> &out, const map<std::string, std::string> &thing) {
-    printf("[C -> C++] testStringMap({");
+    cout << "[C -> C++] testStringMap({";
     map<std::string, std::string>::const_iterator m_iter;
     bool first = true;
     for (m_iter = thing.begin(); m_iter != thing.end(); ++m_iter) {
       if (first) {
         first = false;
       } else {
-        printf(", ");
+        cout << ", ";
       }
-      printf("\"%s\" => \"%s\"", (m_iter->first).c_str(), (m_iter->second).c_str());
+      cout << "\"" << m_iter->first << "\" => \"" << m_iter->second << "\"";
     }
-    printf("})\n");
+    cout << "})" << endl;
     out = thing;
   }
 
 
   void testSet(set<int32_t> &out, const set<int32_t> &thing) {
-    printf("[C -> C++] testSet({");
+    cout << "[C -> C++] testSet({";
     set<int32_t>::const_iterator s_iter;
     bool first = true;
     for (s_iter = thing.begin(); s_iter != thing.end(); ++s_iter) {
       if (first) {
         first = false;
       } else {
-        printf(", ");
+        cout << ", ";
       }
-      printf("%d", *s_iter);
+      cout << *s_iter;
     }
-    printf("})\n");
+    cout << "})" << endl;
     out = thing;
   }
 
   void testList(vector<int32_t> &out, const vector<int32_t> &thing) {
-    printf("[C -> C++] testList({");
+    cout << "[C -> C++] testList({";
     vector<int32_t>::const_iterator l_iter;
     bool first = true;
     for (l_iter = thing.begin(); l_iter != thing.end(); ++l_iter) {
       if (first) {
         first = false;
-      } else {        printf(", ");
+      } else {
+        cout << ", ";
       }
-      printf("%d", *l_iter);
+      cout << *l_iter;
     }
-    printf("})\n");
+    cout << "})" << endl;
     out = thing;
   }
 
   Numberz::type testEnum(const Numberz::type thing) {
-    printf("[C -> C++] testEnum(%d)\n", thing);
+    cout << "[C -> C++] testEnum(" << thing << ")" << endl;
     return thing;
   }
 
   UserId testTypedef(const UserId thing) {
-    printf("[C -> C++] testTypedef(%ld)\n", thing);
+    cout << "[C -> C++] testTypedef(" << thing << ")" << endl;
     return thing;  }
 
   void testMapMap(map<int32_t, map<int32_t,int32_t> > &mapmap, const int32_t hello) {
-    printf("[C -> C++] testMapMap(%d)\n", hello);
+    cout << "[C -> C++] testMapMap(" << hello << ")" << endl;
 
     map<int32_t,int32_t> pos;
     map<int32_t,int32_t> neg;
@@ -197,7 +199,7 @@ class TestHandler : public ThriftTestIf {
   void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
     THRIFT_UNUSED_VARIABLE (argument);
 
-    printf("[C -> C++] testInsanity()\n");
+    cout << "[C -> C++] testInsanity()" << endl;
 
     Xtruct hello;
     hello.string_thing = "Hello2";
@@ -230,37 +232,36 @@ class TestHandler : public ThriftTestIf {
     insane.insert(make_pair(1, first_map));
     insane.insert(make_pair(2, second_map));
 
-    printf("return");
-    printf(" = {");
+    cout << "return = {";
     map<UserId, map<Numberz::type,Insanity> >::const_iterator i_iter;
     for (i_iter = insane.begin(); i_iter != insane.end(); ++i_iter) {
-      printf("%ld => {", i_iter->first);
+      cout << i_iter->first << " => {";
       map<Numberz::type,Insanity>::const_iterator i2_iter;
       for (i2_iter = i_iter->second.begin();
            i2_iter != i_iter->second.end();
            ++i2_iter) {
-        printf("%d => {", i2_iter->first);
+        cout << i2_iter->first << " => {";
         map<Numberz::type, UserId> userMap = i2_iter->second.userMap;
         map<Numberz::type, UserId>::const_iterator um;
-        printf("{");
+        cout << "{";
         for (um = userMap.begin(); um != userMap.end(); ++um) {
-          printf("%d => %ld, ", um->first, um->second);
+          cout << um->first << " => " << um->second << ", ";
         }
-        printf("}, ");
+        cout << "}, ";
 
         vector<Xtruct> xtructs = i2_iter->second.xtructs;
         vector<Xtruct>::const_iterator x;
-        printf("{");
+        cout << "{";
         for (x = xtructs.begin(); x != xtructs.end(); ++x) {
-          printf("{\"%s\", %d, %d, %ld}, ", x->string_thing.c_str(), (int)x->byte_thing, x->i32_thing, x->i64_thing);
+          cout << "{\"" << x->string_thing << "\", " << (int)x->byte_thing << ", " << x->i32_thing << ", " << x->i64_thing << "}, ";
         }
-        printf("}");
+        cout << "}";
 
-        printf("}, ");
+        cout << "}, ";
       }
-      printf("}, ");
+      cout << "}, ";
     }
-    printf("}\n");
+    cout << "}" << endl;
 
 
   }
@@ -270,7 +271,7 @@ class TestHandler : public ThriftTestIf {
     THRIFT_UNUSED_VARIABLE (arg4);
     THRIFT_UNUSED_VARIABLE (arg5);
 
-    printf("[C -> C++] testMulti()\n");
+    cout << "[C -> C++] testMulti()" << endl;
 
     hello.string_thing = "Hello2";
     hello.byte_thing = arg0;
@@ -281,7 +282,7 @@ class TestHandler : public ThriftTestIf {
   void testException(const std::string &arg)
     throw(Xception, apache::thrift::TException)
   {
-    printf("[C -> C++] testException(%s)\n", arg.c_str());
+    cout << "[C -> C++] testException(" << arg << ")" << endl;
     if (arg.compare("Xception") == 0) {
       Xception e;
       e.errorCode = 1001;
@@ -299,7 +300,7 @@ class TestHandler : public ThriftTestIf {
 
   void testMultiException(Xtruct &result, const std::string &arg0, const std::string &arg1) throw(Xception, Xception2) {
 
-    printf("[C -> C++] testMultiException(%s, %s)\n", arg0.c_str(), arg1.c_str());
+    cout << "[C -> C++] testMultiException(" << arg0 << ", " << arg1 << ")" << endl;
 
     if (arg0.compare("Xception") == 0) {
       Xception e;
@@ -318,9 +319,9 @@ class TestHandler : public ThriftTestIf {
   }
 
   void testOneway(int sleepFor) {
-    printf("testOneway(%d): Sleeping...\n", sleepFor);
+    cout << "testOneway(" << sleepFor << "): Sleeping..." << endl;
     sleep(sleepFor);
-    printf("testOneway(%d): done sleeping!\n", sleepFor);
+    cout << "testOneway(" << sleepFor << "): done sleeping!" << endl;
   }
 };
 


[4/9] thrift git commit: THRIFT-3505 Enhance Python TSSLSocket

Posted by ns...@apache.org.
THRIFT-3505 Enhance Python TSSLSocket

This closes #760


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/ad835866
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/ad835866
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/ad835866

Branch: refs/heads/master
Commit: ad8358664e6aa2de9094ca68c8b626b953b572c0
Parents: b78d781
Author: Nobuaki Sukegawa <ns...@apache.org>
Authored: Wed Dec 23 23:32:09 2015 +0900
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Jan 3 02:39:51 2016 +0900

----------------------------------------------------------------------
 appveyor.yml                        |   2 +-
 lib/py/CMakeLists.txt               |   5 +
 lib/py/Makefile.am                  |   6 +-
 lib/py/src/transport/TSSLSocket.py  | 327 ++++++++++++++++++++++---------
 lib/py/test/_import_local_thrift.py |  13 ++
 lib/py/test/test_sslsocket.py       | 275 ++++++++++++++++++++++++++
 lib/py/test/thrift_json.py          |  25 ++-
 test/keys/README.md                 |   8 +-
 test/keys/client.crt                |  27 +--
 test/keys/client.key                |  38 ++--
 test/keys/client.p12                | Bin 1877 -> 2589 bytes
 test/keys/client.pem                |  74 ++++---
 test/known_failures_Linux.json      |   6 +
 13 files changed, 653 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
index 711654e..ee114ae 100755
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -74,6 +74,6 @@ build_script:
 - cmake --build . --config Release
 # TODO: Fix cpack
 # - cpack
-- ctest -C Release -VV -E "(concurrency_test|processor_test|python_test$)"
+- ctest -C Release -VV -E "(concurrency_test|processor_test|python_test$|^Python)"
 
 #TODO make it perfect ;-r

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/lib/py/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/lib/py/CMakeLists.txt b/lib/py/CMakeLists.txt
index ef987b6..7bb91fe 100755
--- a/lib/py/CMakeLists.txt
+++ b/lib/py/CMakeLists.txt
@@ -24,3 +24,8 @@ add_custom_target(python_build ALL
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMENT "Building Python library"
 )
+
+if(BUILD_TESTING)
+    add_test(PythonTestSSLSocket ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/test_sslsocket.py)
+    add_test(PythonThriftJson ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/thrift_json.py)
+endif()

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/lib/py/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/py/Makefile.am b/lib/py/Makefile.am
index c0db871..5183b9c 100755
--- a/lib/py/Makefile.am
+++ b/lib/py/Makefile.am
@@ -23,7 +23,8 @@ if WITH_PY3
 py3-build:
 	$(PYTHON3) setup.py build
 py3-test: py3-build
-	PYTHONPATH=build/lib $(PYTHON3) test/thrift_json.py
+	$(PYTHON3) test/thrift_json.py
+	$(PYTHON3) test/test_sslsocket.py
 else
 py3-build:
 py3-test:
@@ -43,7 +44,8 @@ clean-local:
 	$(RM) -r build
 
 check-local: all py3-test
-	PYTHONPATH=$(shell ls build/lib* -dr | head -n1) $(PYTHON) test/thrift_json.py
+	$(PYTHON) test/thrift_json.py
+	$(PYTHON) test/test_sslsocket.py
 
 EXTRA_DIST = \
 	CMakeLists.txt \

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/lib/py/src/transport/TSSLSocket.py
----------------------------------------------------------------------
diff --git a/lib/py/src/transport/TSSLSocket.py b/lib/py/src/transport/TSSLSocket.py
index 6ad8d50..9be0912 100644
--- a/lib/py/src/transport/TSSLSocket.py
+++ b/lib/py/src/transport/TSSLSocket.py
@@ -17,73 +17,221 @@
 # under the License.
 #
 
+import logging
 import os
 import socket
 import ssl
+import sys
+import warnings
 
 from thrift.transport import TSocket
 from thrift.transport.TTransport import TTransportException
 
+logger = logging.getLogger(__name__)
+warnings.filterwarnings('default', category=DeprecationWarning, module=__name__)
 
-class TSSLSocket(TSocket.TSocket):
+
+class TSSLBase(object):
+  # SSLContext is not available for Python < 2.7.9
+  _has_ssl_context = sys.hexversion >= 0x020709F0
+
+  # ciphers argument is not available for Python < 2.7.0
+  _has_ciphers = sys.hexversion >= 0x020700F0
+
+  # For pythoon >= 2.7.9, use latest TLS that both client and server supports.
+  # SSL 2.0 and 3.0 are disabled via ssl.OP_NO_SSLv2 and ssl.OP_NO_SSLv3.
+  # For pythoon < 2.7.9, use TLS 1.0 since TLSv1_X nare OP_NO_SSLvX are unavailable.
+  _default_protocol = ssl.PROTOCOL_SSLv23 if _has_ssl_context else ssl.PROTOCOL_TLSv1
+
+  def _init_context(self, ssl_version):
+    if self._has_ssl_context:
+      self._context = ssl.SSLContext(ssl_version)
+      if self._context.protocol == ssl.PROTOCOL_SSLv23:
+        self._context.options |= ssl.OP_NO_SSLv2
+        self._context.options |= ssl.OP_NO_SSLv3
+    else:
+      self._context = None
+      self._ssl_version = ssl_version
+
+  @property
+  def ssl_version(self):
+    if self._has_ssl_context:
+      return self.ssl_context.protocol
+    else:
+      return self._ssl_version
+
+  @property
+  def ssl_context(self):
+    return self._context
+
+  SSL_VERSION = _default_protocol
   """
-  SSL implementation of client-side TSocket
+  Default SSL version.
+  For backword compatibility, it can be modified.
+  Use __init__ keywoard argument "ssl_version" instead.
+  """
+
+  def _deprecated_arg(self, args, kwargs, pos, key):
+    if len(args) <= pos:
+      return
+    real_pos = pos + 3
+    warnings.warn(
+        '%dth positional argument is deprecated. Use keyward argument insteand.' % real_pos,
+        DeprecationWarning)
+    if key in kwargs:
+      raise TypeError('Duplicate argument: %dth argument and %s keyward argument.', (real_pos, key))
+    kwargs[key] = args[pos]
+
+  def _unix_socket_arg(self, host, port, args, kwargs):
+    key = 'unix_socket'
+    if host is None and port is None and len(args) == 1 and key not in kwargs:
+      kwargs[key] = args[0]
+      return True
+    return False
+
+  def __getattr__(self, key):
+    if key == 'SSL_VERSION':
+      warnings.warn('Use ssl_version attribute instead.', DeprecationWarning)
+      return self.ssl_version
+
+  def __init__(self, server_side, host, ssl_opts):
+    self._server_side = server_side
+    if TSSLBase.SSL_VERSION != self._default_protocol:
+      warnings.warn('SSL_VERSION is deprecated. Use ssl_version keyward argument instead.', DeprecationWarning)
+    self._context = ssl_opts.pop('ssl_context', None)
+    self._server_hostname = None
+    if not self._server_side:
+      self._server_hostname = ssl_opts.pop('server_hostname', host)
+    if self._context:
+      self._custom_context = True
+      if ssl_opts:
+        raise ValueError('Incompatible arguments: ssl_context and %s' % ' '.join(ssl_opts.keys()))
+      if not self._has_ssl_context:
+        raise ValueError('ssl_context is not available for this version of Python')
+    else:
+      self._custom_context = False
+      ssl_version = ssl_opts.pop('ssl_version', TSSLBase.SSL_VERSION)
+      self._init_context(ssl_version)
+      self.cert_reqs = ssl_opts.pop('cert_reqs', ssl.CERT_REQUIRED)
+      self.ca_certs = ssl_opts.pop('ca_certs', None)
+      self.keyfile = ssl_opts.pop('keyfile', None)
+      self.certfile = ssl_opts.pop('certfile', None)
+      self.ciphers = ssl_opts.pop('ciphers', None)
+
+      if ssl_opts:
+        raise ValueError('Unknown keyword arguments: ', ' '.join(ssl_opts.keys()))
+
+      if self.cert_reqs != ssl.CERT_NONE:
+        if not self.ca_certs:
+          raise ValueError('ca_certs is needed when cert_reqs is not ssl.CERT_NONE')
+        if not os.access(self.ca_certs, os.R_OK):
+          raise IOError('Certificate Authority ca_certs file "%s" '
+                        'is not readable, cannot validate SSL '
+                        'certificates.' % (self.ca_certs))
+
+  @property
+  def certfile(self):
+    return self._certfile
+
+  @certfile.setter
+  def certfile(self, certfile):
+    if self._server_side and not certfile:
+      raise ValueError('certfile is needed for server-side')
+    if certfile and not os.access(certfile, os.R_OK):
+      raise IOError('No such certfile found: %s' % (certfile))
+    self._certfile = certfile
+
+  def _wrap_socket(self, sock):
+    if self._has_ssl_context:
+      if not self._custom_context:
+        self.ssl_context.verify_mode = self.cert_reqs
+        if self.certfile:
+          self.ssl_context.load_cert_chain(self.certfile, self.keyfile)
+        if self.ciphers:
+          self.ssl_context.set_ciphers(self.ciphers)
+        if self.ca_certs:
+          self.ssl_context.load_verify_locations(self.ca_certs)
+      return self.ssl_context.wrap_socket(sock, server_side=self._server_side,
+                                          server_hostname=self._server_hostname)
+    else:
+      ssl_opts = {
+        'ssl_version': self._ssl_version,
+        'server_side': self._server_side,
+        'ca_certs': self.ca_certs,
+        'keyfile': self.keyfile,
+        'certfile': self.certfile,
+        'cert_reqs': self.cert_reqs,
+      }
+      if self.ciphers:
+        if self._has_ciphers:
+          ssl_opts['ciphers'] = self.ciphers
+        else:
+          logger.warning('ciphers is specified but ignored due to old Python version')
+      return ssl.wrap_socket(sock, **ssl_opts)
+
+
+class TSSLSocket(TSocket.TSocket, TSSLBase):
+  """
+  SSL implementation of TSocket
 
   This class creates outbound sockets wrapped using the
   python standard ssl module for encrypted connections.
-
-  The protocol used is set using the class variable
-  SSL_VERSION, which must be one of ssl.PROTOCOL_* and
-  defaults to  ssl.PROTOCOL_TLSv1 for greatest security.
   """
-  SSL_VERSION = ssl.PROTOCOL_TLSv1
-
-  def __init__(self,
-               host='localhost',
-               port=9090,
-               validate=True,
-               ca_certs=None,
-               keyfile=None,
-               certfile=None,
-               unix_socket=None,
-               ciphers=None):
-    """Create SSL TSocket
-
-    @param validate: Set to False to disable SSL certificate validation
-    @type validate: bool
-    @param ca_certs: Filename to the Certificate Authority pem file, possibly a
-    file downloaded from: http://curl.haxx.se/ca/cacert.pem  This is passed to
-    the ssl_wrap function as the 'ca_certs' parameter.
-    @type ca_certs: str
-    @param keyfile: The private key
-    @type keyfile: str
-    @param certfile: The cert file
-    @type certfile: str
-    @param ciphers: The cipher suites to allow. This is passed to
-                    the ssl_wrap function as the 'ciphers' parameter.
-    @type ciphers: str
-    
-    Raises an IOError exception if validate is True and the ca_certs file is
-    None, not present or unreadable.
+
+  # New signature
+  # def __init__(self, host='localhost', port=9090, unix_socket=None, **ssl_args):
+  # Deprecated signature
+  # def __init__(self, host='localhost', port=9090, validate=True, ca_certs=None, keyfile=None, certfile=None, unix_socket=None, ciphers=None):
+  def __init__(self, host='localhost', port=9090, *args, **kwargs):
+    """Positional arguments: ``host``, ``port``, ``unix_socket``
+
+    Keyword arguments: ``keyfile``, ``certfile``, ``cert_reqs``, ``ssl_version``,
+                       ``ca_certs``, ``ciphers`` (Python 2.7.0 or later),
+                       ``server_hostname`` (Python 2.7.9 or later)
+    Passed to ssl.wrap_socket. See ssl.wrap_socket documentation.
+
+    Alternative keywoard arguments: (Python 2.7.9 or later)
+      ``ssl_context``: ssl.SSLContext to be used for SSLContext.wrap_socket
+      ``server_hostname``: Passed to SSLContext.wrap_socket
     """
-    self.validate = validate
     self.is_valid = False
     self.peercert = None
-    if not validate:
-      self.cert_reqs = ssl.CERT_NONE
-    else:
-      self.cert_reqs = ssl.CERT_REQUIRED
-    self.ca_certs = ca_certs
-    self.keyfile = keyfile
-    self.certfile = certfile
-    self.ciphers = ciphers
-    if validate:
-      if ca_certs is None or not os.access(ca_certs, os.R_OK):
-        raise IOError('Certificate Authority ca_certs file "%s" '
-                      'is not readable, cannot validate SSL '
-                      'certificates.' % (ca_certs))
+
+    if args:
+      if len(args) > 6:
+        raise TypeError('Too many positional argument')
+      if not self._unix_socket_arg(host, port, args, kwargs):
+        self._deprecated_arg(args, kwargs, 0, 'validate')
+      self._deprecated_arg(args, kwargs, 1, 'ca_certs')
+      self._deprecated_arg(args, kwargs, 2, 'keyfile')
+      self._deprecated_arg(args, kwargs, 3, 'certfile')
+      self._deprecated_arg(args, kwargs, 4, 'unix_socket')
+      self._deprecated_arg(args, kwargs, 5, 'ciphers')
+
+    validate = kwargs.pop('validate', None)
+    if validate is not None:
+      cert_reqs_name = 'CERT_REQUIRED' if validate else 'CERT_NONE'
+      warnings.warn(
+          'validate is deprecated. Use cert_reqs=ssl.%s instead' % cert_reqs_name,
+          DeprecationWarning)
+      if 'cert_reqs' in kwargs:
+        raise TypeError('Cannot specify both validate and cert_reqs')
+      kwargs['cert_reqs'] = ssl.CERT_REQUIRED if validate else ssl.CERT_NONE
+
+    unix_socket = kwargs.pop('unix_socket', None)
+    TSSLBase.__init__(self, False, host, kwargs)
     TSocket.TSocket.__init__(self, host, port, unix_socket)
 
+  @property
+  def validate(self):
+    warnings.warn('Use cert_reqs instead', DeprecationWarning)
+    return self.cert_reqs != ssl.CERT_NONE
+
+  @validate.setter
+  def validate(self, value):
+    warnings.warn('Use cert_reqs instead', DeprecationWarning)
+    self.cert_reqs = ssl.CERT_REQUIRED if value else ssl.CERT_NONE
+
   def open(self):
     try:
       res0 = self._resolveAddr()
@@ -91,29 +239,24 @@ class TSSLSocket(TSocket.TSocket):
         sock_family, sock_type = res[0:2]
         ip_port = res[4]
         plain_sock = socket.socket(sock_family, sock_type)
-        self.handle = ssl.wrap_socket(plain_sock,
-                                      ssl_version=self.SSL_VERSION,
-                                      do_handshake_on_connect=True,
-                                      ca_certs=self.ca_certs,
-                                      keyfile=self.keyfile,
-                                      certfile=self.certfile,
-                                      cert_reqs=self.cert_reqs,
-                                      ciphers=self.ciphers)
+        self.handle = self._wrap_socket(plain_sock)
         self.handle.settimeout(self._timeout)
         try:
           self.handle.connect(ip_port)
         except socket.error as e:
           if res is not res0[-1]:
+            logger.warning('Error while connecting with %s. Trying next one.', ip_port, exc_info=True)
             continue
           else:
-            raise e
+            raise
         break
     except socket.error as e:
       if self._unix_socket:
         message = 'Could not connect to secure socket %s: %s' \
-                % (self._unix_socket, e)
+                  % (self._unix_socket, e)
       else:
         message = 'Could not connect to %s:%d: %s' % (self.host, self.port, e)
+      logger.error('Error while connecting with %s.', ip_port, exc_info=True)
       raise TTransportException(type=TTransportException.NOT_OPEN,
                                 message=message)
     if self.validate:
@@ -161,38 +304,46 @@ class TSSLSocket(TSocket.TSocket):
               'host "%s".  Cert=%s' % (self.host, cert))
 
 
-class TSSLServerSocket(TSocket.TServerSocket):
+class TSSLServerSocket(TSocket.TServerSocket, TSSLBase):
   """SSL implementation of TServerSocket
 
   This uses the ssl module's wrap_socket() method to provide SSL
   negotiated encryption.
   """
-  SSL_VERSION = ssl.PROTOCOL_TLSv1
 
-  def __init__(self,
-               host=None,
-               port=9090,
-               certfile='cert.pem',
-               unix_socket=None,
-               ciphers=None):
-    """Initialize a TSSLServerSocket
+  # New signature
+  # def __init__(self, host='localhost', port=9090, unix_socket=None, **ssl_args):
+  # Deprecated signature
+  # def __init__(self, host=None, port=9090, certfile='cert.pem', unix_socket=None, ciphers=None):
+  def __init__(self, host=None, port=9090, *args, **kwargs):
+    """Positional arguments: ``host``, ``port``, ``unix_socket``
 
-    @param certfile: filename of the server certificate, defaults to cert.pem
-    @type certfile: str
-    @param host: The hostname or IP to bind the listen socket to,
-                 i.e. 'localhost' for only allowing local network connections.
-                 Pass None to bind to all interfaces.
-    @type host: str
-    @param port: The port to listen on for inbound connections.
-    @type port: int
-    @param ciphers: The cipher suites to allow. This is passed to
-                    the ssl_wrap function as the 'ciphers' parameter.
-    @type ciphers: str
+    Keyword arguments: ``keyfile``, ``certfile``, ``cert_reqs``, ``ssl_version``,
+                       ``ca_certs``, ``ciphers`` (Python 2.7.0 or later)
+    See ssl.wrap_socket documentation.
 
+    Alternative keywoard arguments: (Python 2.7.9 or later)
+      ``ssl_context``: ssl.SSLContext to be used for SSLContext.wrap_socket
+      ``server_hostname``: Passed to SSLContext.wrap_socket
     """
-    self.setCertfile(certfile)
-    TSocket.TServerSocket.__init__(self, host, port)
-    self.ciphers = ciphers
+    if args:
+      if len(args) > 3:
+        raise TypeError('Too many positional argument')
+      if not self._unix_socket_arg(host, port, args, kwargs):
+        self._deprecated_arg(args, kwargs, 0, 'certfile')
+      self._deprecated_arg(args, kwargs, 1, 'unix_socket')
+      self._deprecated_arg(args, kwargs, 2, 'ciphers')
+
+    if 'ssl_context' not in kwargs:
+      # Preserve existing behaviors for default values
+      if 'cert_reqs' not in kwargs:
+        kwargs['cert_reqs'] = ssl.CERT_NONE
+      if'certfile' not in kwargs:
+        kwargs['certfile'] = 'cert.pem'
+
+    unix_socket = kwargs.pop('unix_socket', None)
+    TSSLBase.__init__(self, True, None, kwargs)
+    TSocket.TServerSocket.__init__(self, host, port, unix_socket)
 
   def setCertfile(self, certfile):
     """Set or change the server certificate file used to wrap new connections.
@@ -203,20 +354,18 @@ class TSSLServerSocket(TSocket.TServerSocket):
 
     Raises an IOError exception if the certfile is not present or unreadable.
     """
-    if not os.access(certfile, os.R_OK):
-      raise IOError('No such certfile found: %s' % (certfile))
+    warnings.warn('Use certfile property instead.', DeprecationWarning)
     self.certfile = certfile
 
   def accept(self):
     plain_client, addr = self.handle.accept()
     try:
-      client = ssl.wrap_socket(plain_client, certfile=self.certfile,
-                      server_side=True, ssl_version=self.SSL_VERSION,
-                      ciphers=self.ciphers)
-    except ssl.SSLError as ssl_exc:
+      client = self._wrap_socket(plain_client)
+    except ssl.SSLError:
+      logger.error('Error while accepting from %s', addr, exc_info=True)
       # failed handshake/ssl wrap, close socket to client
       plain_client.close()
-      # raise ssl_exc
+      # raise
       # We can't raise the exception, because it kills most TServer derived
       # serve() methods.
       # Instead, return None, and let the TServer instance deal with it in

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/lib/py/test/_import_local_thrift.py
----------------------------------------------------------------------
diff --git a/lib/py/test/_import_local_thrift.py b/lib/py/test/_import_local_thrift.py
new file mode 100644
index 0000000..30c1abc
--- /dev/null
+++ b/lib/py/test/_import_local_thrift.py
@@ -0,0 +1,13 @@
+import os
+import sys
+
+
+SCRIPT_DIR = os.path.realpath(os.path.dirname(__file__))
+ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPT_DIR)))
+
+if sys.version_info[0] == 2:
+  import glob
+  libdir = glob.glob(os.path.join(ROOT_DIR, 'lib', 'py', 'build', 'lib.*'))[0]
+  sys.path.insert(0, libdir)
+else:
+  sys.path.insert(0, os.path.join(ROOT_DIR, 'lib', 'py', 'build', 'lib'))

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/lib/py/test/test_sslsocket.py
----------------------------------------------------------------------
diff --git a/lib/py/test/test_sslsocket.py b/lib/py/test/test_sslsocket.py
new file mode 100644
index 0000000..bd2a70a
--- /dev/null
+++ b/lib/py/test/test_sslsocket.py
@@ -0,0 +1,275 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import os
+import platform
+import select
+import ssl
+import sys
+import threading
+import time
+import unittest
+import warnings
+
+import _import_local_thrift
+from thrift.transport.TSSLSocket import TSSLSocket, TSSLServerSocket
+
+SCRIPT_DIR = os.path.realpath(os.path.dirname(__file__))
+ROOT_DIR = os.path.dirname(os.path.dirname(os.path.dirname(SCRIPT_DIR)))
+SERVER_PEM = os.path.join(ROOT_DIR, 'test', 'keys', 'server.pem')
+SERVER_CERT = os.path.join(ROOT_DIR, 'test', 'keys', 'server.crt')
+SERVER_KEY = os.path.join(ROOT_DIR, 'test', 'keys', 'server.key')
+CLIENT_CERT = os.path.join(ROOT_DIR, 'test', 'keys', 'client.crt')
+CLIENT_KEY = os.path.join(ROOT_DIR, 'test', 'keys', 'client.key')
+
+TEST_PORT = 23458
+TEST_ADDR = '/tmp/.thrift.domain.sock.%d' % TEST_PORT
+CONNECT_TIMEOUT = 10.0
+TEST_CIPHERS = 'DES-CBC3-SHA'
+
+
+class ServerAcceptor(threading.Thread):
+  def __init__(self, server):
+    super(ServerAcceptor, self).__init__()
+    self._server = server
+    self.client = None
+
+  def run(self):
+    self._server.listen()
+    self.client = self._server.accept()
+
+
+# Python 2.6 compat
+class AssertRaises(object):
+  def __init__(self, expected):
+    self._expected = expected
+
+  def __enter__(self):
+    pass
+
+  def __exit__(self, exc_type, exc_value, traceback):
+    if not exc_type or not issubclass(exc_type, self._expected):
+      raise Exception('fail')
+    return True
+
+
+class TSSLSocketTest(unittest.TestCase):
+  def _assert_connection_failure(self, server, client):
+    try:
+      acc = ServerAcceptor(server)
+      acc.start()
+      time.sleep(0.15)
+      client.setTimeout(CONNECT_TIMEOUT)
+      with self._assert_raises(Exception):
+        client.open()
+        select.select([], [client.handle], [], CONNECT_TIMEOUT)
+      # self.assertIsNone(acc.client)
+      self.assertTrue(acc.client is None)
+    finally:
+      server.close()
+      client.close()
+
+  def _assert_raises(self, exc):
+    if sys.hexversion >= 0x020700F0:
+      return self.assertRaises(exc)
+    else:
+      return AssertRaises(exc)
+
+  def _assert_connection_success(self, server, client):
+    try:
+      acc = ServerAcceptor(server)
+      acc.start()
+      time.sleep(0.15)
+      client.setTimeout(CONNECT_TIMEOUT)
+      client.open()
+      select.select([], [client.handle], [], CONNECT_TIMEOUT)
+      # self.assertIsNotNone(acc.client)
+      self.assertTrue(acc.client is not None)
+    finally:
+      server.close()
+      client.close()
+
+  # deprecated feature
+  def test_deprecation(self):
+    with warnings.catch_warnings(record=True) as w:
+      warnings.filterwarnings('always', category=DeprecationWarning, module='thrift.*SSL.*')
+      TSSLSocket('localhost', TEST_PORT, validate=True, ca_certs=SERVER_CERT)
+      self.assertEqual(len(w), 1)
+
+    with warnings.catch_warnings(record=True) as w:
+      warnings.filterwarnings('always', category=DeprecationWarning, module='thrift.*SSL.*')
+      # Deprecated signature
+      # def __init__(self, host='localhost', port=9090, validate=True, ca_certs=None, keyfile=None, certfile=None, unix_socket=None, ciphers=None):
+      client = TSSLSocket('localhost', TEST_PORT, True, SERVER_CERT, CLIENT_KEY, CLIENT_CERT, None, TEST_CIPHERS)
+      self.assertEqual(len(w), 7)
+
+    with warnings.catch_warnings(record=True) as w:
+      warnings.filterwarnings('always', category=DeprecationWarning, module='thrift.*SSL.*')
+      # Deprecated signature
+      # def __init__(self, host=None, port=9090, certfile='cert.pem', unix_socket=None, ciphers=None):
+      server = TSSLServerSocket(None, TEST_PORT, SERVER_PEM, None, TEST_CIPHERS)
+      self.assertEqual(len(w), 3)
+
+    self._assert_connection_success(server, client)
+
+  # deprecated feature
+  def test_set_cert_reqs_by_validate(self):
+    c1 = TSSLSocket('localhost', TEST_PORT, validate=True, ca_certs=SERVER_CERT)
+    self.assertEqual(c1.cert_reqs, ssl.CERT_REQUIRED)
+
+    c1 = TSSLSocket('localhost', TEST_PORT, validate=False)
+    self.assertEqual(c1.cert_reqs, ssl.CERT_NONE)
+
+  # deprecated feature
+  def test_set_validate_by_cert_reqs(self):
+    c1 = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_NONE)
+    self.assertFalse(c1.validate)
+
+    c2 = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_REQUIRED, ca_certs=SERVER_CERT)
+    self.assertTrue(c2.validate)
+
+    c3 = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_OPTIONAL, ca_certs=SERVER_CERT)
+    self.assertTrue(c3.validate)
+
+  def test_unix_domain_socket(self):
+    if platform.system() == 'Windows':
+      print('skipping test_unix_domain_socket')
+      return
+    server = TSSLServerSocket(unix_socket=TEST_ADDR, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+    client = TSSLSocket(None, None, TEST_ADDR, cert_reqs=ssl.CERT_NONE)
+    self._assert_connection_success(server, client)
+
+  def test_server_cert(self):
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+    client = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_REQUIRED, ca_certs=SERVER_CERT)
+    self._assert_connection_success(server, client)
+
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+    # server cert on in ca_certs
+    client = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_REQUIRED, ca_certs=CLIENT_CERT)
+    self._assert_connection_failure(server, client)
+
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+    client = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_NONE)
+    self._assert_connection_success(server, client)
+
+  def test_set_server_cert(self):
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=CLIENT_CERT)
+    with self._assert_raises(Exception):
+      server.certfile = 'foo'
+    with self._assert_raises(Exception):
+      server.certfile = None
+    server.certfile = SERVER_CERT
+    client = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_REQUIRED, ca_certs=SERVER_CERT)
+    self._assert_connection_success(server, client)
+
+  def test_client_cert(self):
+    server = TSSLServerSocket(
+        port=TEST_PORT, cert_reqs=ssl.CERT_REQUIRED, keyfile=SERVER_KEY,
+        certfile=SERVER_CERT, ca_certs=CLIENT_CERT)
+    client = TSSLSocket('localhost', TEST_PORT, cert_reqs=ssl.CERT_NONE, certfile=CLIENT_CERT, keyfile=CLIENT_KEY)
+    self._assert_connection_success(server, client)
+
+  def test_ciphers(self):
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ciphers=TEST_CIPHERS)
+    client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ciphers=TEST_CIPHERS)
+    self._assert_connection_success(server, client)
+
+    if not TSSLSocket._has_ciphers:
+      # unittest.skip is not available for Python 2.6
+      print('skipping test_ciphers')
+      return
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+    client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ciphers='NULL')
+    self._assert_connection_failure(server, client)
+
+    server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ciphers=TEST_CIPHERS)
+    client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ciphers='NULL')
+    self._assert_connection_failure(server, client)
+
+  def test_ssl2_and_ssl3_disabled(self):
+    if not hasattr(ssl, 'PROTOCOL_SSLv3'):
+      print('PROTOCOL_SSLv3 is not available')
+    else:
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ssl_version=ssl.PROTOCOL_SSLv3)
+      self._assert_connection_failure(server, client)
+
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ssl_version=ssl.PROTOCOL_SSLv3)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT)
+      self._assert_connection_failure(server, client)
+
+    if not hasattr(ssl, 'PROTOCOL_SSLv2'):
+      print('PROTOCOL_SSLv2 is not available')
+    else:
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ssl_version=ssl.PROTOCOL_SSLv2)
+      self._assert_connection_failure(server, client)
+
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ssl_version=ssl.PROTOCOL_SSLv2)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT)
+      self._assert_connection_failure(server, client)
+
+  def test_newer_tls(self):
+    if not TSSLSocket._has_ssl_context:
+      # unittest.skip is not available for Python 2.6
+      print('skipping test_newer_tls')
+      return
+    if not hasattr(ssl, 'PROTOCOL_TLSv1_2'):
+      print('PROTOCOL_TLSv1_2 is not available')
+    else:
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ssl_version=ssl.PROTOCOL_TLSv1_2)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ssl_version=ssl.PROTOCOL_TLSv1_2)
+      self._assert_connection_success(server, client)
+
+    if not hasattr(ssl, 'PROTOCOL_TLSv1_1'):
+      print('PROTOCOL_TLSv1_1 is not available')
+    else:
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ssl_version=ssl.PROTOCOL_TLSv1_1)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ssl_version=ssl.PROTOCOL_TLSv1_1)
+      self._assert_connection_success(server, client)
+
+    if not hasattr(ssl, 'PROTOCOL_TLSv1_1') or not hasattr(ssl, 'PROTOCOL_TLSv1_2'):
+      print('PROTOCOL_TLSv1_1 and/or PROTOCOL_TLSv1_2 is not available')
+    else:
+      server = TSSLServerSocket(port=TEST_PORT, keyfile=SERVER_KEY, certfile=SERVER_CERT, ssl_version=ssl.PROTOCOL_TLSv1_2)
+      client = TSSLSocket('localhost', TEST_PORT, ca_certs=SERVER_CERT, ssl_version=ssl.PROTOCOL_TLSv1_1)
+      self._assert_connection_failure(server, client)
+
+  def test_ssl_context(self):
+    if not TSSLSocket._has_ssl_context:
+      # unittest.skip is not available for Python 2.6
+      print('skipping test_ssl_context')
+      return
+    server_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
+    server_context.load_cert_chain(SERVER_CERT, SERVER_KEY)
+    server_context.load_verify_locations(CLIENT_CERT)
+
+    client_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
+    client_context.load_cert_chain(CLIENT_CERT, CLIENT_KEY)
+    client_context.load_verify_locations(SERVER_CERT)
+
+    server = TSSLServerSocket(port=TEST_PORT, ssl_context=server_context)
+    client = TSSLSocket('localhost', TEST_PORT, ssl_context=client_context)
+    self._assert_connection_success(server, client)
+
+if __name__ == '__main__':
+  # import logging
+  # logging.basicConfig(level=logging.DEBUG)
+  unittest.main()

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/lib/py/test/thrift_json.py
----------------------------------------------------------------------
diff --git a/lib/py/test/thrift_json.py b/lib/py/test/thrift_json.py
index 6d6c8fa..e60aaba 100644
--- a/lib/py/test/thrift_json.py
+++ b/lib/py/test/thrift_json.py
@@ -1,10 +1,29 @@
-from thrift import Thrift
-from thrift.protocol.TJSONProtocol import TJSONProtocol
-from thrift.transport import TTransport
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
 
 import sys
 import unittest
 
+import _import_local_thrift
+from thrift.protocol.TJSONProtocol import TJSONProtocol
+from thrift.transport import TTransport
+
 #
 # In order to run the test under Windows. We need to create symbolic link
 # name 'thrift' to '../src' folder by using:

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/test/keys/README.md
----------------------------------------------------------------------
diff --git a/test/keys/README.md b/test/keys/README.md
index 53fe0cc..15faa51 100755
--- a/test/keys/README.md
+++ b/test/keys/README.md
@@ -26,7 +26,7 @@ we use the following parameters for test key and certificate creation
     openssl x509 -in server.crt -text > CA.pem
     cat server.crt server.key > server.pem
 
-Export password is **thrift**
+Export password is "thrift" without the quotes
 
     openssl pkcs12 -export -clcerts -in server.crt -inkey server.key -out server.p12
 
@@ -40,9 +40,9 @@ create a signing request:
 
 sign the client certificate with the server.key
 
-    openssl x509 -req -days 365 -in client.csr -CA CA.pem -CAkey server.key -set_serial 01 -out client.crt
+    openssl x509 -req -days 3000 -in client.csr -CA CA.pem -CAkey server.key -set_serial 01 -out client.crt
 
-export certificate in PKCS12 format (Export password is **thrift**)
+export certificate in PKCS12 format (Export password is "thrift" without the quotes)
 
     openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12
 
@@ -52,7 +52,7 @@ export certificate in PEM format for OpenSSL usage
 
 
 ## Java key and certificate import
-Java Test Environment uses key and trust store password **thrift**
+Java Test Environment uses key and trust store password "thrift" without the quotes
 
 list keystore entries
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/test/keys/client.crt
----------------------------------------------------------------------
diff --git a/test/keys/client.crt b/test/keys/client.crt
index 64526f6..80a9ad0 100644
--- a/test/keys/client.crt
+++ b/test/keys/client.crt
@@ -1,20 +1,23 @@
 -----BEGIN CERTIFICATE-----
-MIIDVDCCAjwCAQEwDQYJKoZIhvcNAQEFBQAwgbExCzAJBgNVBAYTAlVTMREwDwYD
+MIID2DCCAsACAQEwDQYJKoZIhvcNAQELBQAwgbExCzAJBgNVBAYTAlVTMREwDwYD
 VQQIDAhNYXJ5bGFuZDEUMBIGA1UEBwwLRm9yZXN0IEhpbGwxJzAlBg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vYlZtnhvhJ+tMkoR
-Kbxl1VUYxx+jzfhBy+bKu5uGZB3F1qtyY9fI5DQut75nNbueQPG+qw==
+BgkqhkiG9w0BCQEWFWRldkB0aHJpZnQuYXBhY2hlLm9yZzCCASIwDQYJKoZIhvcN
+AQEBBQADggEPADCCAQoCggEBALl/bJhg17Pu1t785JIuwlh7e2E51eoWFvuxMWfH
+dsUAVqDaOz99O5sv8pgWKXrkPBttE98T+Mx/Pwz5JHs4Qcre3A5adm6cdab0AKug
+eVG1PvHrWzV4aheg4KUfVSiMz8BG2K3Q1VGvZkgMRa/Q409FKjU6Z4D9vBG4Pas3
+PN5FxnAL6P70yWCEr2Vu/tWJlCN+qrRDfSaE2hqmT1irxaoPa61GvuRVsGQ3TeoE
+mGfENtvFqC6qQWuSCbG5aI47Rv66pqoWWxqkrcolNc7+vhx6rW+wdFO3IlqIT8IG
+sdQVp+Y4ir/dGp2ejzqGZCremPJ1uEKjLMpIukdg25ymHC0CAwEAATANBgkqhkiG
+9w0BAQsFAAOCAQEABcRdwc9mdY9zOvTixtThHrciVvqwp6RaiQqMEVomozYilZDR
+J90M3H6KnlADJbCv0FXujsaApB53awq5I7sObAYWFhDJZ9LKlw0lDF7KchLXiAlk
+XVyvL2nJjuJcxPCFPWktwrw5bTguRCBzG12Hzikn+xs6uPur7VQYM33jbXEda5PS
+UEqvAVWaONJCX8MDYOscVoJF0ESyI+fN92ipFaXR7fGajod/rc0AfeN2GVMZETve
+21pkUyDwwCGA44uvNUCd1e32NxE3ah9UApCRn5sGJ64R6urpFTXT3IALF3kaOO7U
+VsMhFrUiZ7+Bw5nIeiK0QOF6Eipj+bJvrLZpSg==
 -----END CERTIFICATE-----

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/test/keys/client.key
----------------------------------------------------------------------
diff --git a/test/keys/client.key b/test/keys/client.key
index 703e045..25dcfd7 100644
--- a/test/keys/client.key
+++ b/test/keys/client.key
@@ -1,15 +1,27 @@
 -----BEGIN RSA PRIVATE K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GrDlKug9TKg3
+sAvZYO5tyINqHuyuTFywHFcpbtjIN9PnM+fPPD7+IpVFh6gkfoMdo2VHJ62+iWOd
+xg475s6jLT1t7GFmYQzA8QOuUCMAYKT9Ks6UMjHthc3skwJpAqvPSUVuBBBGVWH7
+dFUBAoGBAL67ARLujiAEVNHt5rajixB6ncl7/R+Z2uawI1JfmdnCZonAKVZYHuXU
+/4j2+o4QhJIPLtWIoaxAkMigQtAkesqirn3Kk/c7kZRIoN549HTJuwZqYqNp7CB/
+kVi5R335+M9z49i6qA0RZsJGSoSBk7PufG4RmLimcRbGwrY93sPD
 -----END RSA PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/test/keys/client.p12
----------------------------------------------------------------------
diff --git a/test/keys/client.p12 b/test/keys/client.p12
index a7d95df..5d2669c 100644
Binary files a/test/keys/client.p12 and b/test/keys/client.p12 differ

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/test/keys/client.pem
----------------------------------------------------------------------
diff --git a/test/keys/client.pem b/test/keys/client.pem
index ee5bc61..66ef626 100644
--- a/test/keys/client.pem
+++ b/test/keys/client.pem
@@ -1,44 +1,60 @@
 Bag Attributes
-    localKeyID: 05 3C 6A 9D 6D EC A0 FA 2F AE 41 32 0D 24 3A 21 34 F6 08 15 
+    localKeyID: 39 EC 3D 5B 28 17 DA DD 09 7A 62 68 D5 44 1F C7 E2 F8 E0 CD 
 subject=/C=US/ST=Maryland/L=Forest Hill/O=The Apache Software Foundation/OU=Apache Thrift/CN=localhost/emailAddress=dev@thrift.apache.org
 issuer=/C=US/ST=Maryland/L=Forest Hill/O=The Apache Software Foundation/OU=Apache Thrift/CN=localhost/emailAddress=dev@thrift.apache.org
 -----BEGIN CERTIFICATE-----
-MIIDVDCCAjwCAQEwDQYJKoZIhvcNAQEFBQAwgbExCzAJBgNVBAYTAlVTMREwDwYD
+MIID2DCCAsACAQEwDQYJKoZIhvcNAQELBQAwgbExCzAJBgNVBAYTAlVTMREwDw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n/WdxCjHd
-NyeWxlDlmzc2+uOeVF5sIGzFOj/qjGxc+UyUXaaEuSvh7j3rvYlZtnhvhJ+tMkoR
-Kbxl1VUYxx+jzfhBy+bKu5uGZB3F1qtyY9fI5DQut75nNbueQPG+qw==
+BgkqhkiG9w0BCQEWFWRldkB0aHJpZnQuYXBhY2hlLm9yZzCCASIwDQYJKoZIhvcN
+AQEBBQADggEPADCCAQoCggEBALl/bJhg17Pu1t785JIuwlh7e2E51eoWFvuxMWfH
+dsUAVqDaOz99O5sv8pgWKXrkPBttE98T+Mx/Pwz5JHs4Qcre3A5adm6cdab0AKug
+eVG1PvHrWzV4aheg4KUfVSiMz8BG2K3Q1VGvZkgMRa/Q409FKjU6Z4D9vBG4Pas3
+PN5FxnAL6P70yWCEr2Vu/tWJlCN+qrRDfSaE2hqmT1irxaoPa61GvuRVsGQ3TeoE
+mGfENtvFqC6qQWuSCbG5aI47Rv66pqoWWxqkrcolNc7+vhx6rW+wdFO3IlqIT8IG
+sdQVp+Y4ir/dGp2ejzqGZCremPJ1uEKjLMpIukdg25ymHC0CAwEAATANBgkqhkiG
+9w0BAQsFAAOCAQEABcRdwc9mdY9zOvTixtThHrciVvqwp6RaiQqMEVomozYilZDR
+J90M3H6KnlADJbCv0FXujsaApB53awq5I7sObAYWFhDJZ9LKlw0lDF7KchLXiAlk
+XVyvL2nJjuJcxPCFPWktwrw5bTguRCBzG12Hzikn+xs6uPur7VQYM33jbXEda5PS
+UEqvAVWaONJCX8MDYOscVoJF0ESyI+fN92ipFaXR7fGajod/rc0AfeN2GVMZETve
+21pkUyDwwCGA44uvNUCd1e32NxE3ah9UApCRn5sGJ64R6urpFTXT3IALF3kaOO7U
+VsMhFrUiZ7+Bw5nIeiK0QOF6Eipj+bJvrLZpSg==
 -----END CERTIFICATE-----
 Bag Attributes
-    localKeyID: 05 3C 6A 9D 6D EC A0 FA 2F AE 41 32 0D 24 3A 21 34 F6 08 15 
+    localKeyID: 39 EC 3D 5B 28 17 DA DD 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jhdyTrl86EQHH33dh+Sua8AhfewPRy2VFp3Zk34AUsWcX
+EfIYGemhqUD3drG0SMVbFFNOaFGp9e0tQouYOC6/qFBv/SNgQz3mAEkciJYbUuUZ
+V4YQPvtdvSrISV0e7bjFgdSEjG7P7F6CFrWTrjUlHZuWj6/rJ3+/1PHeJViyhsrJ
+ZYFe14W/48PDxBRl4IEAmxcN1Eb2Ez9eCqv0HW77HviG6zIgnkPrhWHjFGUpxKk4
+jLfuB2Tfq9F7ozv4L2QAn+F/yKt1Rm2Hh5J61eUJtAT60pajg+gJtjmpu5Pr4HDn
+b6p3xmYwaL5Let1zCAbbMfdlDK14YjdOdM/BEKpXb9y4EIubX5AMY4ljXeG9gx+T
+B1TuQVdJ0P5wIK/D10TQzAWDKam0kv3RXidlzRxpZ3snRnN/L3EVd58Rntj1Oc0y
+FiIiSKRszDbPzKDxQE2sNgQcdO24JNLSa/sZYtq2gRgspl/YqIDo4ZYqi9x8F5OS
+rdPU5D/H8LWR4vpJLL8DYrHh5qFG3BX2OJIhPRS+48pDYtrRjp7S/1ZU64OJAytk
+99hDqSrn1j2a6yFE8L2Ptz+4UCF2OQXEc9Rqqeb8QEUuMSkNH4oQ+A2F6uzLpZi0
+XH64R2niNC56LxV2i+3T5KREFLahyk8epLZlv8YdxYR4Sb7J/5yiooK3g9hmYVKO
+zLc=
 -----END ENCRYPTED PRIVATE KEY-----

http://git-wip-us.apache.org/repos/asf/thrift/blob/ad835866/test/known_failures_Linux.json
----------------------------------------------------------------------
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index aabbfbf..648215a 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -41,6 +41,12 @@
   "csharp-nodejs_json_framed-ip-ssl",
   "csharp-perl_binary_buffered-ip-ssl",
   "csharp-perl_binary_framed-ip-ssl",
+  "csharp-py3_binary_buffered-ip-ssl",
+  "csharp-py3_binary_framed-ip-ssl",
+  "csharp-py3_compact_buffered-ip-ssl",
+  "csharp-py3_compact_framed-ip-ssl",
+  "csharp-py3_json_buffered-ip-ssl",
+  "csharp-py3_json_framed-ip-ssl",
   "erl-cpp_compact_buffered-ip",
   "erl-cpp_compact_buffered-ip-ssl",
   "erl-cpp_compact_framed-ip",


[8/9] thrift git commit: THRIFT-3486 - Java generated `getFieldValue` is incompatible with `setFieldValue` for binary values Client: Java Patch: BCG

Posted by ns...@apache.org.
THRIFT-3486 - Java generated `getFieldValue` is incompatible with `setFieldValue` for binary values
Client: Java
Patch: BCG

This closes #743


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/2aaae8a6
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/2aaae8a6
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/2aaae8a6

Branch: refs/heads/master
Commit: 2aaae8a604c9a3f000926250a8446b7b850355c7
Parents: bf8f7b4
Author: BCG <bg...@users.noreply.github.com>
Authored: Sun Dec 13 16:05:13 2015 -0500
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Jan 3 02:55:16 2016 +0900

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_java_generator.cc   | 11 +++++++
 lib/java/test/org/apache/thrift/TestStruct.java | 30 +++++++++++++++++++-
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/2aaae8a6/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 9080368..f711f2d 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -2064,12 +2064,23 @@ void t_java_generator::generate_reflection_setters(ostringstream& out,
                                                    t_type* type,
                                                    string field_name,
                                                    string cap_name) {
+  const bool is_binary = type->is_base_type() && ((t_base_type*)type)->is_binary();
   indent(out) << "case " << constant_name(field_name) << ":" << endl;
   indent_up();
   indent(out) << "if (value == null) {" << endl;
   indent(out) << "  unset" << get_cap_name(field_name) << "();" << endl;
   indent(out) << "} else {" << endl;
+  if (is_binary) {
+    indent_up();
+    indent(out) << "if (value instanceof byte[]) {" << endl;
+    indent(out) << "  set" << cap_name << "((byte[])value);" << endl;
+    indent(out) << "} else {" << endl;
+  }
   indent(out) << "  set" << cap_name << "((" << type_name(type, true, false) << ")value);" << endl;
+  if (is_binary) {
+    indent(out) << "}" << endl;
+    indent_down();
+  }
   indent(out) << "}" << endl;
   indent(out) << "break;" << endl << endl;
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/2aaae8a6/lib/java/test/org/apache/thrift/TestStruct.java
----------------------------------------------------------------------
diff --git a/lib/java/test/org/apache/thrift/TestStruct.java b/lib/java/test/org/apache/thrift/TestStruct.java
index b0dffc8..3379ed1 100644
--- a/lib/java/test/org/apache/thrift/TestStruct.java
+++ b/lib/java/test/org/apache/thrift/TestStruct.java
@@ -308,12 +308,40 @@ public class TestStruct extends TestCase {
         object.toString());
   }
 
+  private static void assertArrayEquals(byte[] expected, byte[] actual) {
+    if (!java.util.Arrays.equals(expected, actual)) {
+      fail("Expected byte array did not match actual.");
+    }
+  }
+
   public void testBytesBufferFeatures() throws Exception {
-    JavaTestHelper o = new JavaTestHelper();
+    
+    final String testString = "testBytesBufferFeatures";
+    final JavaTestHelper o = new JavaTestHelper();
+
     o.setReq_bin((ByteBuffer)null);
     assertNull(o.getReq_bin());
+
+    o.setReq_bin(ByteBuffer.wrap(testString.getBytes()));
+    assertArrayEquals(testString.getBytes(), o.getReq_bin());
+
     o.setReq_bin((byte[])null);
     assertNull(o.getReq_bin());
+
+    o.setReq_bin(testString.getBytes());
+    assertArrayEquals(testString.getBytes(), o.getReq_bin());
+
+    o.setFieldValue(JavaTestHelper._Fields.REQ_BIN, null);
+    assertNull(o.getReq_bin());
+
+    o.setFieldValue(JavaTestHelper._Fields.REQ_BIN, testString.getBytes());
+    assertArrayEquals(testString.getBytes(), o.getReq_bin());
+
+    o.setFieldValue(JavaTestHelper._Fields.REQ_BIN, null);
+    assertNull(o.getReq_bin());
+
+    o.setFieldValue(JavaTestHelper._Fields.REQ_BIN, ByteBuffer.wrap(testString.getBytes()));
+    assertArrayEquals(testString.getBytes(), o.getReq_bin());
   }
 
   public void testJavaSerializable() throws Exception {


[9/9] thrift git commit: THRIFT-3502: C++ TServerSocket passes small buffer to getsockname Client: C++ Patch: Jeremy Spiegel

Posted by ns...@apache.org.
THRIFT-3502: C++ TServerSocket passes small buffer to getsockname
Client: C++
Patch: Jeremy Spiegel

This closes #761


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/269473d4
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/269473d4
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/269473d4

Branch: refs/heads/master
Commit: 269473d4750a1e03ff0c85125bfa20b2f2475aa3
Parents: 2aaae8a
Author: Jeremy Spiegel <js...@box.com>
Authored: Tue Dec 22 16:19:20 2015 -0800
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Jan 3 02:55:16 2016 +0900

----------------------------------------------------------------------
 lib/cpp/src/thrift/transport/TServerSocket.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/269473d4/lib/cpp/src/thrift/transport/TServerSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TServerSocket.cpp b/lib/cpp/src/thrift/transport/TServerSocket.cpp
index 137dc32..347da4d 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -494,14 +494,14 @@ void TServerSocket::listen() {
 
     // retrieve bind info
     if (port_ == 0 && retries <= retryLimit_) {
-      struct sockaddr sa;
+      struct sockaddr_storage sa;
       socklen_t len = sizeof(sa);
       std::memset(&sa, 0, len);
-      if (::getsockname(serverSocket_, &sa, &len) < 0) {
+      if (::getsockname(serverSocket_, reinterpret_cast<struct sockaddr*>(&sa), &len) < 0) {
         int errno_copy = errno;
         GlobalOutput.perror("TServerSocket::getPort() getsockname() ", errno_copy);
       } else {
-        if (sa.sa_family == AF_INET6) {
+        if (sa.ss_family == AF_INET6) {
           const struct sockaddr_in6* sin = reinterpret_cast<const struct sockaddr_in6*>(&sa);
           port_ = ntohs(sin->sin6_port);
         } else {