Skip to content

Commit

Permalink
Merge pull request #53 from node-modules/fix-hashmap-1.x
Browse files Browse the repository at this point in the history
fix: hashmap tag should be 0x4d
  • Loading branch information
coolme200 committed Nov 1, 2015
2 parents b9ff862 + f5cf1fb commit ffce1d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/v2/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ proto._writeListBegin = function (length, type) {
proto._writeHashMap = function (obj) {
debug('_writeHashMap() %j, fields: %j', obj);

this.byteBuffer.put(0x48); // H
this.byteBuffer.put(0x4d); // M

if (SUPPORT_ES6_MAP && obj instanceof Map) {
obj.forEach(function (value, key) {
Expand Down
6 changes: 3 additions & 3 deletions test/map.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ describe('map.test.js', function () {
// pass if not support es6 Map
return;
}
var generic = new Buffer('48f87bd5e2403de240c87b7a', 'hex');
var generic = new Buffer('4df87bd5e2403de240c87b7a', 'hex');
var map = new Map();
map.set({ '$class': 'java.lang.Long', '$': 123 }, 123456);
map.set({ '$class': 'java.lang.Long', '$': 123456 }, 123);
Expand Down Expand Up @@ -278,14 +278,14 @@ describe('map.test.js', function () {

it('should write js object to no type hash map', function () {
var encoder = new hessian.EncoderV2();
var fooEmpty = new Buffer('4803666f6f007a', 'hex');
var fooEmpty = new Buffer('4d03666f6f007a', 'hex');
var buf = encoder.write({ foo: '' }).get();
buf.should.eql(fooEmpty);
hessian.decode(fooEmpty, '2.0').should.eql({
foo: ''
});

var fooBar = new Buffer('4803313233c9c803666f6f03626172047a65726f9005e4b8ade696876b657909e4b8ade69687e59388e5938876616c75657a', 'hex');
var fooBar = new Buffer('4d03313233c9c803666f6f03626172047a65726f9005e4b8ade696876b657909e4b8ade69687e59388e5938876616c75657a', 'hex');
encoder = new hessian.EncoderV2();
buf = encoder.write({
foo: 'bar',
Expand Down

0 comments on commit ffce1d8

Please sign in to comment.