From b5b3056b7b7b9acc58a0c19ad31fb474e3b70f27 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Fri, 12 Aug 2016 17:19:44 +0800 Subject: [PATCH 1/2] remove regexp for performance --- lib/v1/decoder.js | 2 +- lib/v2/decoder.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/v1/decoder.js b/lib/v1/decoder.js index bc04fc6..46efb18 100644 --- a/lib/v1/decoder.js +++ b/lib/v1/decoder.js @@ -423,7 +423,7 @@ proto.readObject = function (withType) { debug('read object finish'); // java.lang.NoClassDefFoundError - if (/Exception$/.test(type) || /^java\.lang\.\w+Error$/.test(type)) { + if (type.endsWith('Exception') || (type.startsWith('java.lang.') && type.endsWith('Error'))) { result.$ = new JavaExceptionError(result, withType); } diff --git a/lib/v2/decoder.js b/lib/v2/decoder.js index 8d8db34..82a9c5d 100644 --- a/lib/v2/decoder.js +++ b/lib/v2/decoder.js @@ -571,7 +571,7 @@ proto.readObject = function (withType) { } else { this.throwError('readObject', code); } - + var cls = this.classes[ref]; debug('readObject %s, ref: %s', cls.name, ref); @@ -590,7 +590,7 @@ proto.readObject = function (withType) { } } - if (/Exception$/.test(cls.name)) { + if (cls.name.endsWith('Exception')) { result.$ = new JavaExceptionError(result, withType); } @@ -759,7 +759,7 @@ utils.addByteCodes(BYTE_CODES, [ * v2.0 * ``` * map ::= M(x4d) [type] (value value)* Z - * + * * @see http://hessian.caucho.com/doc/hessian-serialization.html##map * ``` * Represents serialized maps and can represent objects. @@ -801,7 +801,7 @@ proto.readMap = function (withType) { this._addRef(result); this._readMap(result.$, withType); - if (/Exception$/.test(type)) { + if (type.endsWith('Exception')) { result.$ = new JavaExceptionError(result); } From bb73d333da9a43fb0a405c5fb224ebfb3c9c61f5 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Fri, 12 Aug 2016 17:20:12 +0800 Subject: [PATCH 2/2] remove support for v0.10, v0.12, v1, v2, v3 --- .travis.yml | 7 +------ package.json | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9bec0b6..36701b5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,8 @@ sudo: false language: node_js node_js: - - '5' + - '6' - '4' - - '3' - - '2' - - '1' - - '0.12' - - '0.10' script: - "npm run ci" after_script: diff --git a/package.json b/package.json index 1e5769e..82af3d9 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,6 @@ "should": "5" }, "engines": { - "node": ">= 0.10.0" + "node": ">= 4" } }