From e967ad8e4d896864800e21e1c27c711b84c70be2 Mon Sep 17 00:00:00 2001 From: James Giller Date: Tue, 3 Oct 2017 14:33:10 +0900 Subject: [PATCH 1/2] Fix bug with hasParam and getParamNames. The function "methodCall" was being incorrectly called on an object of type XmlrpcClient. "methodCall" is actually defined for a property of instances of XmlrpcClient, so this was a simple issue of missing indirection. XmlrpcClient is a wrapper that defines a "call" function as an interface, and delegates to an object from the xmlrpc module by calling its "methodCall". This commit changes the implementatino of hasParam and getParamNames to use "call" instead of "methodCall", adding the missing layer of indirection. --- src/lib/ParamServerApiClient.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/lib/ParamServerApiClient.js b/src/lib/ParamServerApiClient.js index 166a77c..d33ab1f 100644 --- a/src/lib/ParamServerApiClient.js +++ b/src/lib/ParamServerApiClient.js @@ -88,15 +88,14 @@ class ParamServerApiClient { ]; return new Promise((resolve, reject) => { - this._xmlrpcClient.methodCall('hasParam', data, (err, resp) => { - if (err || resp[0] !== 1) { - reject(err, resp); - } - else { + this._call('hasParam', data, (resp) => { + if (resp[0] !== 1) { + reject(resp); + } else { // resp[2] is whether it actually has param and presumably all anyone cares about resolve(resp[2]); } - }); + }, reject); }); } @@ -106,15 +105,14 @@ class ParamServerApiClient { ]; return new Promise((resolve, reject) => { - this._xmlrpcClient.methodCall('getParamNames', data, (err, resp) => { - if (err || resp[0] !== 1) { - reject(err, resp); - } - else { + this._call('getParamNames', data, (resp) => { + if (resp[0] !== 1) { + reject(resp); + } else { // resp[2] is parameter name list and presumably all anyone cares about resolve(resp[2]); } - }); + }, reject); }); } } From ac56329e3ca1214d1917f82343507f98f1a23186 Mon Sep 17 00:00:00 2001 From: James Giller Date: Wed, 4 Oct 2017 10:27:05 +0900 Subject: [PATCH 2/2] Remove redundant check that response code equals 1. XmlrpcClient should check if the response code is not 1 and automatically reject the call. --- src/lib/ParamServerApiClient.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/lib/ParamServerApiClient.js b/src/lib/ParamServerApiClient.js index d33ab1f..d8079fb 100644 --- a/src/lib/ParamServerApiClient.js +++ b/src/lib/ParamServerApiClient.js @@ -89,12 +89,8 @@ class ParamServerApiClient { return new Promise((resolve, reject) => { this._call('hasParam', data, (resp) => { - if (resp[0] !== 1) { - reject(resp); - } else { - // resp[2] is whether it actually has param and presumably all anyone cares about - resolve(resp[2]); - } + // resp[2] is whether it actually has param and presumably all anyone cares about + resolve(resp[2]); }, reject); }); } @@ -106,12 +102,8 @@ class ParamServerApiClient { return new Promise((resolve, reject) => { this._call('getParamNames', data, (resp) => { - if (resp[0] !== 1) { - reject(resp); - } else { - // resp[2] is parameter name list and presumably all anyone cares about - resolve(resp[2]); - } + // resp[2] is parameter name list and presumably all anyone cares about + resolve(resp[2]); }, reject); }); }