From aff2f78b27566145c6bbcb827d4ae472f3ee215b Mon Sep 17 00:00:00 2001 From: henrique Date: Mon, 9 Sep 2013 12:38:25 +0200 Subject: [PATCH] THRIFT-2167 nodejs lib throws error if options argument isn't passed Client: nodejs Patch: Randy Abernethy and Red Daly also add examples to test makefile --- compiler/cpp/src/generate/t_js_generator.cc | 2 +- lib/nodejs/lib/thrift/connection.js | 20 ++++++++++---------- test/nodejs/Makefile.am | 8 +++++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/compiler/cpp/src/generate/t_js_generator.cc b/compiler/cpp/src/generate/t_js_generator.cc index 565bb805..7c42c019 100644 --- a/compiler/cpp/src/generate/t_js_generator.cc +++ b/compiler/cpp/src/generate/t_js_generator.cc @@ -1010,7 +1010,7 @@ void t_js_generator::generate_service_client(t_service* tservice) { // utils for multiplexed services if (gen_node_) { indent(f_service_) << js_namespace(tservice->get_program())<get_program())<get_program())< functions = tservice->get_functions(); diff --git a/lib/nodejs/lib/thrift/connection.js b/lib/nodejs/lib/thrift/connection.js index 4581d819..8303b08f 100644 --- a/lib/nodejs/lib/thrift/connection.js +++ b/lib/nodejs/lib/thrift/connection.js @@ -35,20 +35,20 @@ var Connection = exports.Connection = function(stream, options) { this.offline_queue = []; this.connected = false; - this._debug = options.debug || false; - if (options.max_attempts - && !isNaN(options.max_attempts) && options.max_attempts > 0) { - this.max_attempts = +options.max_attempts; + this._debug = this.options.debug || false; + if (this.options.max_attempts + && !isNaN(this.options.max_attempts) && this.options.max_attempts > 0) { + this.max_attempts = +this.options.max_attempts; } this.retry_max_delay = null; - if (options.retry_max_delay !== undefined - && !isNaN(options.retry_max_delay) && options.retry_max_delay > 0) { - this.retry_max_delay = options.retry_max_delay; + if (this.options.retry_max_delay !== undefined + && !isNaN(this.options.retry_max_delay) && this.options.retry_max_delay > 0) { + this.retry_max_delay = this.options.retry_max_delay; } this.connect_timeout = false; - if (options.connect_timeout - && !isNaN(options.connect_timeout) && options.connect_timeout > 0) { - this.connect_timeout = +options.connect_timeout; + if (this.options.connect_timeout + && !isNaN(this.options.connect_timeout) && this.options.connect_timeout > 0) { + this.connect_timeout = +this.options.connect_timeout; } this.connection.addListener("connect", function() { self.connected = true; diff --git a/test/nodejs/Makefile.am b/test/nodejs/Makefile.am index ab9a554f..a8c10aa5 100755 --- a/test/nodejs/Makefile.am +++ b/test/nodejs/Makefile.am @@ -30,12 +30,14 @@ check: stubs echo " Testing Client/Server"; \ timeout -s14 5 $(MAKE) server & \ sleep 1; $(MAKE) client; sleep 2; \ - fi - - @if which node &> /dev/null ; then \ + \ echo " Testing Multiplex Client/Server"; \ sleep 4; timeout -s14 5 $(MAKE) mserver & \ sleep 1; $(MAKE) mclient; sleep 2; \ + \ + echo " Testing Client/Server examples"; \ + sleep 4; timeout -s14 5 $(MAKE) -C ../../lib/nodejs/examples server & \ + sleep 1; $(MAKE) -C ../../lib/nodejs/examples client; sleep 2; \ fi clean-local: -- 2.17.1