[
https://issues.apache.org/jira/browse/THRIFT-4174?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jens Geyer reassigned THRIFT-4174:
----------------------------------
Assignee: Jens Geyer
Description:
The {{js:jquery}} option produces code that does not work inj async mode. The
code works fine in synchronous mode, but not when called with a callback, where
any exceptions thrown seem not to be delivered correctly.
was:
The {{js:jquery}} option produces code that calls {{flush()}} in an incorect
way which essentially prevents it from working. The code works fine in
synchronous mode, but not when called with a callback.
{code}
SampleSvc.SampleClient.prototype.Bar = function(sText, callback) {
if (callback === undefined) {
this.send_Bar(sText);
return this.recv_Bar();
} else {
var postData = this.send_Bar(sText, true);
return this.output.getTransport()
.jqRequest(this, postData, arguments, this.recv_Bar);
}
};
SampleSvc.SampleClient.prototype.send_Bar = function(sText, callback) {
this.output.writeMessageBegin('Bar', Thrift.MessageType.CALL, this.seqid);
var args = new SampleSvc.Sample_Bar_args();
args.sText = sText;
args.write(this.output);
this.output.writeMessageEnd();
return this.output.getTransport().flush(callback);
};
{code}
Note that {{true}} instead of the callback func is passed to
{{this.send_Bar(sText, true);}}, hence the callback function is already lost at
that stage. This value of {{true}} is then passed to {{return
this.output.getTransport().flush(callback);}}. It get's even more wrong if we
look at what flush() really expects:
{code}
/**
* Sends the current XRH request if the transport was created with a URL
* and the async parameter is false. If the transport was not created with
* a URL, or the async parameter is True and no callback is provided, or
* the URL is an empty string, the current send buffer is returned.
* @param {object} async - If true the current send buffer is returned.
* @param {object} callback - Optional async completion callback
* @returns {undefined|string} Nothing or the current send buffer.
* @throws {string} If XHR fails.
*/
flush: function(async, callback) {
var self = this;
if ((async && !callback) || this.url === undefined || this.url === '') {
return this.send_buf;
}
// ... more code ...
{code}
Summary: js:jquery option broken? (was: js:jquery option generates
broken code for async mode)
> js:jquery option broken?
> ------------------------
>
> Key: THRIFT-4174
> URL: https://issues.apache.org/jira/browse/THRIFT-4174
> Project: Thrift
> Issue Type: Bug
> Components: JavaScript - Compiler
> Reporter: Jens Geyer
> Assignee: Jens Geyer
>
> The {{js:jquery}} option produces code that does not work inj async mode. The
> code works fine in synchronous mode, but not when called with a callback,
> where any exceptions thrown seem not to be delivered correctly.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)