Skip to content

Commit c141e2a

Browse files
committed
Fix #42 - Serialization of non-ascii characters may result in an incomplete payload being sent across the wire
1 parent e1ad602 commit c141e2a

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

etc/jvm-args.txt

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
-Xmx1g
88
-Dcoherence.cluster=test-cluster
99
-Dcoherence.log.level=9
10+
-Dcoherence.io.json.debug=true
1011
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005"

package-lock.json

+12-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@oracle/coherence",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"license": "UPL-1.0",
55
"main": "lib/index.js",
66
"keywords": [
@@ -12,7 +12,8 @@
1212
"repository": "https://github.com/oracle/coherence-js-client",
1313
"dependencies": {
1414
"@grpc/proto-loader": "^0.6",
15-
"@grpc/grpc-js": "^1.6"
15+
"@grpc/grpc-js": "^1.6",
16+
"google-protobuf": "^3.20"
1617
},
1718
"devDependencies": {
1819
"grpc-tools": "^1.11.1",

src/util.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -1553,13 +1553,9 @@ export namespace util {
15531553
* @inheritDoc
15541554
*/
15551555
public serialize (obj: any): Buffer {
1556-
const str = JSON.stringify(obj)
1557-
const buf = Buffer.alloc(str.length + 1)
1558-
1559-
buf.writeInt8(JSONSerializer.JSON_SERIALIZER_PREFIX, 0) // Write at index 0
1560-
buf.write(str, 1) // Write at index 1
1561-
1562-
return buf
1556+
return Buffer.concat(
1557+
[Buffer.from(JSONSerializer.JSON_SERIALIZER_PREFIX.toString()),
1558+
Buffer.from(JSON.stringify(obj))]);
15631559
}
15641560

15651561
/**

0 commit comments

Comments
 (0)