Skip to content

Commit

Permalink
bug fix for issue #609
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Aug 12, 2022
1 parent 7ee4f1d commit 353f70c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public long readFieldNameHashCode() {
c = (char) bytes[offset];
}
if (c != ':') {
return -1;
throw new JSONException(info("expect ':', but " + c));
}

offset++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ public long readFieldNameHashCode() {
ch = EOI;
}
if (c != ':') {
return -1;
throw new JSONException(info("expect ':', but " + c));
}

offset++;
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/com/alibaba/fastjson2/JSONReaderUTF8.java
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ public long readFieldNameHashCode() {
c = bytes[offset];
}
if (c != ':') {
return -1;
// return -1;
throw new JSONException(info("expect ':', but " + c));
}

offset++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ public long readFieldNameHashCode() {
ch = EOI;
}
if (c != ':') {
return -1;
throw new JSONException(info("expect ':', but " + c));
}

offset++;
Expand Down
23 changes: 23 additions & 0 deletions core/src/test/java/com/alibaba/fastjson2/issues/Issue669.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.alibaba.fastjson2.issues;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONException;
import lombok.Data;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertThrows;

public class Issue669 {
@Test
public void test() {
assertThrows(
JSONException.class,
() -> JSON.parseArray("[\"3330354\"]", Bean.class)
);
}

@Data
public static class Bean {
private String a;
}
}

0 comments on commit 353f70c

Please sign in to comment.