From 3f0b392c58a9b5e65915eca55bc209439ba1e3db Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Fri, 3 Aug 2018 15:02:49 +0800 Subject: [PATCH] fix: should reset _classRefFields (#87) https://github.com/node-modules/hessian.js/pull/86/files#r145311196 --- lib/v2/encoder.js | 2 +- test/v2.list.encode.test.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/v2/encoder.js b/lib/v2/encoder.js index 52c5f04..ad9565e 100644 --- a/lib/v2/encoder.js +++ b/lib/v2/encoder.js @@ -13,8 +13,8 @@ function Encoder(options) { EncoderV1.call(this, options); this._classRefs = []; - this._typeRefs = []; this._classRefFields = {}; + this._typeRefs = []; } util.inherits(Encoder, EncoderV1); diff --git a/test/v2.list.encode.test.js b/test/v2.list.encode.test.js index 41a935b..b6264b1 100644 --- a/test/v2.list.encode.test.js +++ b/test/v2.list.encode.test.js @@ -8,9 +8,7 @@ var utils = require('../lib/utils'); var java = require('js-to-java'); describe('hessian v2', function () { - - it('v2 list encode should ok', function() { - + it('v2 list encode should ok', function () { var arg = { "$class": "com.x.Site", "$": { @@ -205,6 +203,9 @@ describe('hessian v2', function () { var rs = hessian.decode(bytes, '2.0'); assert.deepEqual(java.revert(arg), rs); + hessian.encoderV2.reset(); + assert(hessian.encoderV2._classRefs.length === 0); + assert(hessian.encoderV2._typeRefs.length === 0); + assert(Object.keys(hessian.encoderV2._classRefFields).length === 0); }); - });