-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast-Json解析gzip压缩的数据,不抛出异常,反而是直接返回null,对于定位问题很难定位,希望解决此BUG #3614
Milestone
Comments
1.2.75这个地方也没变,问题应该还是存在,请问能够提供一个最小demo吗 |
/**
* GZIP 压缩
*/
private static byte[] gzip(byte[] source) throws IOException {
if (source == null) return null;
try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(bos)) {
gzip.write(source);
return bos.toByteArray();
}
}
@Test
public void fastJsonBugTest() throws IOException {
byte[] gzipBytes = gzip(JSON.toJSONString(Collections.singletonMap("key", "value")).getBytes());
System.out.println(JSON.parseObject(gzipBytes, JSONObject.class) == null); // 输出 true
} |
1.2.83也是有这个问题的 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
version:1.2.72
问题代码: com.alibaba.fastjson.JSON#parseObject, line 435
解决方式,希望直接抛出异常:
理由:1)fastjson对于非json的符合编码字符串,直接抛出异常,为什么不对不符合字符编码的抛出异常
2)由于业务中经常遇到编码问题,这种隐式问题还希望及时抛出问题,即时定位问题
The text was updated successfully, but these errors were encountered: