Skip to content

Commit 60fc9df

Browse files
committed
Fixed deserialization of JSON objects that contain empty keys (#170)
1 parent 604079d commit 60fc9df

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/com/github/shyiko/mysql/binlog/event/deserialization/json/JsonBinary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ protected long readBigEndianLong(int numBytes) throws IOException {
872872

873873
protected int readUnsignedIndex(int maxValue, boolean isSmall, String desc) throws IOException {
874874
long result = isSmall ? readUInt16() : readUInt32();
875-
if (result >= maxValue) {
875+
if (result > maxValue) {
876876
throw new IOException("The " + desc + " the JSON document is " + result +
877877
" and is too big for the binary form of the document (" + maxValue + ")");
878878
}

src/test/java/com/github/shyiko/mysql/binlog/event/deserialization/json/JsonBinaryValueIntegrationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ public void testJsonObjectNested() throws Exception {
205205
assertJSONMatchOriginal("{\"a\":{\"b\":{\"c\":\"d\",\"e\":[\"f\",\"g\"]}}}");
206206
}
207207

208+
@Test
209+
public void testJsonWithEmptyKey() throws Exception {
210+
assertJSONMatchOriginal("{\"bitrate\":{\"\":0}}");
211+
}
212+
208213
@Test
209214
public void testJsonArray() throws Exception {
210215
assertJSONMatchOriginal(

0 commit comments

Comments
 (0)