[ https://issues.apache.org/jira/browse/THRIFT-815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12887686#action_12887686 ]
Jordan edited comment on THRIFT-815 at 7/13/10 4:03 AM: -------------------------------------------------------- I don't know what's *supposed* to happen, but around line 510-530 in thrift.js seems wrong. When we read a list, we delete an element off of the front of the list, and pop it on top of the rstack, then around the the following part of the code, we treat the object that we just popped on top of the stack, as if it were a field of an object itself. It is NOT. It is an object, not a field of an object. So things are failing because of this, and I'm not sure why we were popping an object on top in the first place. Can someone look at this? <javascript> //remove so we don't see it again delete this.rstack[this.rstack.length-1][fid] this.rstack.push(field) break } if(fid != -1){ //should only be 1 of these but this is the only //way to match a key for(var f in (this.rstack[this.rstack.length-1])){ if(Thrift.Protocol.RType[f] == null ) continue ftype = Thrift.Protocol.RType[f] this.rstack[this.rstack.length-1] = this.rstack[this.rstack.length-1][f] } } </code> was (Author: jordo): I don't know what's *supposed* to happen, but around line 510-530 in thrift.js seems wrong. When we read a list, we delete an element off of the front of the list, and pop it on top of the rstack, then around the the following part of the code, we treat the object that we just popped on top of the stack, as if it were a field of an object itself. It is NOT. It is an object, not a field of an object. So things are failing because of this, and I'm not sure why we were popping an object on top in the first place. Can someone look at this? <code> //remove so we don't see it again delete this.rstack[this.rstack.length-1][fid] this.rstack.push(field) break } if(fid != -1){ //should only be 1 of these but this is the only //way to match a key for(var f in (this.rstack[this.rstack.length-1])){ if(Thrift.Protocol.RType[f] == null ) continue // it thinks that rstack[this.rstack.length-1] is an object with native fields ftype = Thrift.Protocol.RType[f] this.rstack[this.rstack.length-1] = this.rstack[this.rstack.length-1][f] } } </code> > Deserialization of lists is critically broken. > ---------------------------------------------- > > Key: THRIFT-815 > URL: https://issues.apache.org/jira/browse/THRIFT-815 > Project: Thrift > Issue Type: Bug > Components: Compiler (JavaScript) > Affects Versions: 0.4 > Reporter: Jordan > Assignee: T Jake Luciani > Priority: Critical > Fix For: 0.4 > > Attachments: 813-1.patch, test.html, THRIFT-815_thrift.js.patch > > > Edit the test code that comes with the js language target: > var list = [1,2,3]; > var ret = client.testList(list); > debugger; > ret comes back as [3,3,3] when it should be echoed back as [1,2,3] > The test case never caught this because it only verified the size, and not > the contents of the returned array. > I cannot find an immediate workaround, but I will try wrapping it in a dummy > type like ListServiceResponse. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.