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 2015/11/08 16:04:24 UTC
[1/3] thrift git commit: THRIFT-3199 Uses StructMetaData for
exception fieldvalue Client: Compiler(Java, javame, as3) Patch: Laurent Goujon
Repository: thrift
Updated Branches:
refs/heads/master 8a4d06feb -> 5b15f8c55
THRIFT-3199 Uses StructMetaData for exception fieldvalue
Client: Compiler(Java, javame, as3)
Patch: Laurent Goujon
This closes #526
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/11c35697
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/11c35697
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/11c35697
Branch: refs/heads/master
Commit: 11c3569720853d3339b82fc0231d54260ccf5fa8
Parents: 8a4d06f
Author: Laurent Goujon <lg...@twitter.com>
Authored: Tue Jun 23 23:07:08 2015 -0700
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Sun Nov 8 23:59:40 2015 +0900
----------------------------------------------------------------------
compiler/cpp/src/generate/t_as3_generator.cc | 2 +-
compiler/cpp/src/generate/t_java_generator.cc | 2 +-
compiler/cpp/src/generate/t_javame_generator.cc | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/11c35697/compiler/cpp/src/generate/t_as3_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_as3_generator.cc b/compiler/cpp/src/generate/t_as3_generator.cc
index 9b878c0..0364ec1 100644
--- a/compiler/cpp/src/generate/t_as3_generator.cc
+++ b/compiler/cpp/src/generate/t_as3_generator.cc
@@ -1370,7 +1370,7 @@ void t_as3_generator::generate_field_value_meta_data(std::ofstream& out, t_type*
out << endl;
indent_up();
indent_up();
- if (type->is_struct()) {
+ if (type->is_struct() || type->is_xception()) {
indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type);
} else if (type->is_container()) {
if (type->is_list()) {
http://git-wip-us.apache.org/repos/asf/thrift/blob/11c35697/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 236e942..9da52d1 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -2593,7 +2593,7 @@ void t_java_generator::generate_field_value_meta_data(std::ofstream& out, t_type
out << endl;
indent_up();
indent_up();
- if (type->is_struct()) {
+ if (type->is_struct() || type->is_xception()) {
indent(out) << "new "
"org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType."
"STRUCT, " << type_name(type) << ".class";
http://git-wip-us.apache.org/repos/asf/thrift/blob/11c35697/compiler/cpp/src/generate/t_javame_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_javame_generator.cc b/compiler/cpp/src/generate/t_javame_generator.cc
index 0b4d553..219d24c 100644
--- a/compiler/cpp/src/generate/t_javame_generator.cc
+++ b/compiler/cpp/src/generate/t_javame_generator.cc
@@ -1816,7 +1816,7 @@ void t_javame_generator::generate_field_value_meta_data(std::ofstream& out, t_ty
out << endl;
indent_up();
indent_up();
- if (type->is_struct()) {
+ if (type->is_struct() || type->is_xception()) {
indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type) << ".class";
} else if (type->is_container()) {
if (type->is_list()) {
[2/3] thrift git commit: THRIFT-1522: Fixes Memory leak by wrapping
getaddrinfo into a class. Client: C++ Patch: Claudius Heine
Posted by ns...@apache.org.
THRIFT-1522: Fixes Memory leak by wrapping getaddrinfo into a class.
Client: C++
Patch: Claudius Heine
Sponsored-by: Roger Meier <r....@siemens.com>
Signed-off-by: Claudius Heine <ch...@denx.de>
This closes #542
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/d8ddb775
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/d8ddb775
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/d8ddb775
Branch: refs/heads/master
Commit: d8ddb775e4330050e04cefa711f60250905978d3
Parents: 11c3569
Author: Claudius Heine <ch...@denx.de>
Authored: Mon Jul 6 09:14:25 2015 +0200
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Mon Nov 9 00:02:18 2015 +0900
----------------------------------------------------------------------
lib/cpp/src/thrift/transport/TServerSocket.cpp | 48 ++++++++++++++++++---
1 file changed, 42 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/d8ddb775/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 0c973ee..215cda6 100644
--- a/lib/cpp/src/thrift/transport/TServerSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TServerSocket.cpp
@@ -75,6 +75,42 @@ void destroyer_of_fine_sockets(THRIFT_SOCKET* ssock) {
delete ssock;
}
+class TGetAddrInfoWrapper {
+public:
+ TGetAddrInfoWrapper(const char* node, const char* service, const struct addrinfo* hints);
+
+ virtual ~TGetAddrInfoWrapper();
+
+ int init();
+ const struct addrinfo* res();
+
+private:
+ const char* node_;
+ const char* service_;
+ const struct addrinfo* hints_;
+ struct addrinfo* res_;
+};
+
+TGetAddrInfoWrapper::TGetAddrInfoWrapper(const char* node,
+ const char* service,
+ const struct addrinfo* hints)
+ : node_(node), service_(service), hints_(hints), res_(NULL) {}
+
+TGetAddrInfoWrapper::~TGetAddrInfoWrapper() {
+ if (this->res_ != NULL)
+ freeaddrinfo(this->res_);
+}
+
+int TGetAddrInfoWrapper::init() {
+ if (this->res_ == NULL)
+ return getaddrinfo(this->node_, this->service_, this->hints_, &(this->res_));
+ return 0;
+}
+
+const struct addrinfo* TGetAddrInfoWrapper::res() {
+ return this->res_;
+}
+
namespace apache {
namespace thrift {
namespace transport {
@@ -236,7 +272,8 @@ void TServerSocket::listen() {
throw TTransportException(TTransportException::BAD_ARGS, "Specified port is invalid");
}
- struct addrinfo hints, *res, *res0;
+ struct addrinfo hints;
+ const struct addrinfo *res;
int error;
char port[sizeof("65535")];
std::memset(&hints, 0, sizeof(hints));
@@ -246,7 +283,9 @@ void TServerSocket::listen() {
sprintf(port, "%d", port_);
// If address is not specified use wildcard address (NULL)
- error = getaddrinfo(address_.empty() ? NULL : &address_[0], port, &hints, &res0);
+ TGetAddrInfoWrapper info(address_.empty() ? NULL : &address_[0], port, &hints);
+
+ error = info.init();
if (error) {
GlobalOutput.printf("getaddrinfo %d: %s", error, THRIFT_GAI_STRERROR(error));
close();
@@ -256,7 +295,7 @@ void TServerSocket::listen() {
// Pick the ipv6 address first since ipv4 addresses can be mapped
// into ipv6 space.
- for (res = res0; res; res = res->ai_next) {
+ for (res = info.res(); res; res = res->ai_next) {
if (res->ai_family == AF_INET6 || res->ai_next == NULL)
break;
}
@@ -453,9 +492,6 @@ void TServerSocket::listen() {
// use short circuit evaluation here to only sleep if we need to
} while ((retries++ < retryLimit_) && (THRIFT_SLEEP_SEC(retryDelay_) == 0));
- // free addrinfo
- freeaddrinfo(res0);
-
// retrieve bind info
if (port_ == 0 && retries <= retryLimit_) {
struct sockaddr sa;
[3/3] thrift git commit: THRIFT-3307 Raise an error when trying to
serialize a union with an incorrect set_field Client: Ruby Patch: Joe Ennever
Posted by ns...@apache.org.
THRIFT-3307 Raise an error when trying to serialize a union with an incorrect set_field
Client: Ruby
Patch: Joe Ennever
This closes #597
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/5b15f8c5
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/5b15f8c5
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/5b15f8c5
Branch: refs/heads/master
Commit: 5b15f8c55f8f26644f40a9ccbbf339f6f84dacd0
Parents: d8ddb77
Author: Joe Ennever <jo...@dwnld.me>
Authored: Mon Aug 31 19:20:36 2015 +0000
Committer: Nobuaki Sukegawa <ns...@apache.org>
Committed: Mon Nov 9 00:02:23 2015 +0900
----------------------------------------------------------------------
lib/rb/ext/struct.c | 6 +++++-
lib/rb/spec/union_spec.rb | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/5b15f8c5/lib/rb/ext/struct.c
----------------------------------------------------------------------
diff --git a/lib/rb/ext/struct.c b/lib/rb/ext/struct.c
index f500d03..e3aa855 100644
--- a/lib/rb/ext/struct.c
+++ b/lib/rb/ext/struct.c
@@ -290,7 +290,7 @@ static void write_container(int ttype, VALUE field_info, VALUE value, VALUE prot
if (TYPE(value) == T_ARRAY) {
items = value;
- } else {
+ } else {
if (rb_cSet == CLASS_OF(value)) {
items = rb_funcall(value, entries_method_id, 0);
} else {
@@ -670,6 +670,10 @@ static VALUE rb_thrift_union_write(VALUE self, VALUE protocol) {
VALUE field_info = rb_hash_aref(struct_fields, field_id);
+ if(NIL_P(field_info)) {
+ rb_raise(rb_eRuntimeError, "set_field is not valid for this union!");
+ }
+
VALUE ttype_value = rb_hash_aref(field_info, type_sym);
int ttype = FIX2INT(ttype_value);
http://git-wip-us.apache.org/repos/asf/thrift/blob/5b15f8c5/lib/rb/spec/union_spec.rb
----------------------------------------------------------------------
diff --git a/lib/rb/spec/union_spec.rb b/lib/rb/spec/union_spec.rb
index a427090..6ad3194 100644
--- a/lib/rb/spec/union_spec.rb
+++ b/lib/rb/spec/union_spec.rb
@@ -48,6 +48,13 @@ describe 'Union' do
lambda { union.some_characters }.should raise_error(RuntimeError, "some_characters is not union's set field.")
end
+ it "should raise for wrong set field when hash initialized and type checking is off" do
+ Thrift.type_checking = false
+ union = SpecNamespace::My_union.new({incorrect_field: :incorrect})
+ example = lambda { Thrift::Serializer.new.serialize(union) }
+ example.should raise_error(RuntimeError, "set_field is not valid for this union!")
+ end
+
it "should not be equal to nil" do
union = SpecNamespace::My_union.new
union.should_not == nil