{ "id": "87932", "key": "TIMOB-7996", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-06-15T18:30:25.000+0000", "created": "2012-03-14T11:14:06.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "parity" ], "versions": [ { "id": "13070", "description": "Release 1.8 Service Pack 2", "name": "Release 1.8.2", "archived": true, "released": true, "releaseDate": "2012-02-29" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-06-15T18:30:25.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": "10224", "name": "TiAPI", "description": "This component is used for cross-platform API work. Specifications are most likely to use this component." } ], "description": "If writeStream(inputStream, outputStream, chunkSize, callback) is invoked when the input stream is at end of stream, behavior varies by platform. Neither platform appears to follow the spec.\r\n\r\nFrom my reading of the spec, it's not clear what's supposed to happen. For the pump callback it specifically says that the bytesProcessed property in the callback arg is set to -1 on end of stream. \r\n\r\nOn iOS, an exception is thrown, so the callback isn't invoked.\r\n\r\nOn Android, bytesProcessed is set to 0 in the callback, errorState is 0, and errorDescription is \"\". \r\n\r\nIt seems like it would be more consistent with other functionality if bytesProcessed reported -1 in both cases.\r\n\r\nSame behavior holds for the synchronous version of the method--returns 0 on Android, throws an exception on iOS.\r\n\r\nIf we regard passing an empty stream (or a stream at EOF) as an error, we should treat it as an error on both platforms.\r\n\r\nTestcase:\r\n\r\n{code}\r\nvar win1 = Titanium.UI.createWindow({ \r\n title:'Tab 1',\r\n backgroundColor:'#fff'\r\n});\r\nwin1.open();\r\n\r\nvar stream1 = Ti.Stream.createStream({ \r\n\tsource: Ti.createBuffer({ length: 0}),\r\n\tmode: Ti.Stream.MODE_READ\r\n});\r\n\r\nvar stream2 = Ti.Stream.createStream({ \r\n\tsource: Ti.createBuffer({ length: 1024}),\r\n\tmode: Ti.Stream.MODE_READ\r\n});\r\n\r\nTi.Stream.writeStream(stream1, stream2, 1024, function(arg) {\r\n\tTi.API.info(\"bytes processed: \" + arg.bytesProcessed);\r\n\tTi.API.info(\"Event: \" + JSON.stringify(arg, false, 2));\r\n});\r\n{code}\r\n\r\nPlease clarify expected behavior.", "attachment": [], "flagged": false, "summary": "Ti API: Stream.writeStream--different handling for end of stream", "creator": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "aevans", "key": "aevans", "displayName": "Arthur Evans", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "422077", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket due to time passed and lack of progress in the past few years. Any problems, please file a new ticket.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-06-15T18:30:25.000+0000", "updated": "2017-06-15T18:30:25.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }