From 76d55f635784aa9dfae8ce52ce3eb49ba7f90a40 Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Tue, 22 Feb 2011 20:56:45 +0000 Subject: [PATCH] THRIFT-1065 JavaScript read-undefined-exceptions2 Patch: Henrique Mendonca git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1073497 13f79535-47bb-0310-9956-ffa450edef68 --- lib/js/thrift.js | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/js/thrift.js b/lib/js/thrift.js index 3ce1f74c..dc74eb6a 100644 --- a/lib/js/thrift.js +++ b/lib/js/thrift.js @@ -86,25 +86,17 @@ Thrift.TApplicationException = function(message, code){ Thrift.TApplicationException.prototype = { read : function(input){ - - var ftype - var fid - var ret = input.readStructBegin(fname) - - this.fname = ret.fname - while(1){ - ret = input.readFieldBegin() - if(ret.ftype == TType.STOP) + if(ret.ftype == Thrift.Type.STOP) break var fid = ret.fid switch(fid){ case 1: - if( ret.ftype == Type.STRING ){ + if( ret.ftype == Thrift.Type.STRING ){ ret = input.readString() this.message = ret.value } else { @@ -113,7 +105,7 @@ Thrift.TApplicationException.prototype = { break case 2: - if( ret.ftype == Type.I32 ){ + if( ret.ftype == Thrift.Type.I32 ){ ret = input.readI32() this.code = ret.value } else { @@ -127,11 +119,9 @@ Thrift.TApplicationException.prototype = { } input.readFieldEnd() - } input.readStructEnd() - }, write: function(output){ @@ -140,20 +130,19 @@ Thrift.TApplicationException.prototype = { output.writeStructBegin('TApplicationException'); if (this.message) { - output.writeFieldBegin('message', Type.STRING, 1) + output.writeFieldBegin('message', Thrift.Type.STRING, 1) output.writeString(this.getMessage()) output.writeFieldEnd() } if (this.code) { - output.writeFieldBegin('type', Type.I32, 2) + output.writeFieldBegin('type', Thrift.Type.I32, 2) output.writeI32(this.code) output.writeFieldEnd() } output.writeFieldStop() output.writeStructEnd() - }, getCode : function() { -- 2.17.1