{ "id": "82645", "key": "AC-2905", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2011-12-26T05:41:37.000+0000", "created": "2011-11-11T12:26:34.000+0000", "labels": [ "HTTPClient" ], "versions": [], "issuelinks": [], "assignee": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "updated": "2016-03-08T07:47:52.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "Creating an XHR with: var xhr = Titanium.Network.createHTTPClient()\r\nand then setting the callback with: xhr.onreadystatechange = this.func.bind(null, this)\r\n\r\nFollowing the \"xhr.send(data)\", I observe the proper TCP packets being sent to the server and the proper response coming back from the server. However, immediately following the \"xhr.send(data)\", the system throws:\r\n\r\nE/KrollCallback( 314): (kroll$1: app://app.js) [282,3299] Error, invocation: [callMethod Network.HTTPClient.(anonymous) org.appcelerator.titanium.kroll.KrollCallback@45118288], message: null\r\nE/KrollCallback( 314): java.lang.IllegalStateException\r\nE/KrollCallback( 314): \tat org.mozilla.javascript.ScriptRuntime.getTopCallScope(ScriptRuntime.java:3159)\r\nE/KrollCallback( 314): \tat org.mozilla.javascript.BoundFunction.call(BoundFunction.java:82)\r\nE/KrollCallback( 314): \tat org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139)\r\nE/KrollCallback( 314): \tat org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164)\r\nE/KrollCallback( 314): \tat android.os.Handler.handleCallback(Handler.java:587)\r\nE/KrollCallback( 314): \tat android.os.Handler.dispatchMessage(Handler.java:92)\r\nE/KrollCallback( 314): \tat android.os.Looper.loop(Looper.java:123)\r\nE/KrollCallback( 314): \tat org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)\r\n\r\nIf I remove the bind from the callback function then it works as it should (except that I don't have \"this\" in the parameter list of the callback.\r\n\r\n", "attachment": [], "flagged": false, "summary": "HttpClient \"bound\" callbacks not working", "creator": { "name": "mike@introspect.com", "key": "mike@introspect.com", "displayName": "Michael Welter", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mike@introspect.com", "key": "mike@introspect.com", "displayName": "Michael Welter", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "OS X, Titanium Studio 1.7.5, Android Emulator", "comment": { "comments": [ { "id": "172858", "author": { "name": "mike@introspect.com", "key": "mike@introspect.com", "displayName": "Michael Welter", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The software works as it should on the iPhone simulator.", "updateAuthor": { "name": "mike@introspect.com", "key": "mike@introspect.com", "displayName": "Michael Welter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-15T17:31:17.000+0000", "updated": "2011-11-15T17:31:17.000+0000" }, { "id": "173122", "author": { "name": "mike@introspect.com", "key": "mike@introspect.com", "displayName": "Michael Welter", "active": true, "timeZone": "America/Los_Angeles" }, "body": "The following workaround seems to solve the problem:\r\n\r\nAdd the following member to Function:\r\n Function.prototype.prependArg = function (arg)\r\n {\r\n var func = this;\r\n\r\n return function () {\r\n var newargs = [arg];\r\n for (var i = 0; i < arguments.length; i++) {\r\n newargs.push(arguments[i]);\r\n }\r\n return func.apply(this, newargs);\r\n };\r\n };\r\n\r\nChange the xhr callback to:\r\n xhr.onreadystatechange = this.func.prependArg(this);", "updateAuthor": { "name": "mike@introspect.com", "key": "mike@introspect.com", "displayName": "Michael Welter", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-17T10:24:55.000+0000", "updated": "2011-11-17T10:24:55.000+0000" }, { "id": "177187", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Thanks for raising this ticket.\r\n\r\nIn order for me to escalate it to the core team, all the fields must be complete. Please check it against the [JIRA Ticket Checklist|https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist], and add any missing information.\r\n\r\nFurthermore, a test case must run without modification, as per the [Creating a Test Case|https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-CreatingaTestCase] section.\r\n\r\nI will close this for now. Please reopen it once it is complete, and I will move it to the main project.\r\n\r\nCheers", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-12-26T05:41:27.000+0000", "updated": "2011-12-26T05:41:27.000+0000" }, { "id": "183586", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "Closing due to inactivity. If this issue still exists, please raise a new ticket, including all the information in the [JIRA Ticket Checklist|https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist] to ensure that we can escalate it quickly. Read [How to Submit a Bug Report|https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report] if you have not read it before, and always start a ticket using the [JIRA Ticket Template|https://wiki.appcelerator.org/display/guides/JIRA+Ticket+Template].\r\n\r\nThanks in advance", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2012-02-17T02:23:19.000+0000", "updated": "2012-02-17T02:23:19.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }