-
Notifications
You must be signed in to change notification settings - Fork 510
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
[BUG]JSONObject 转换字符串 boolean类型的属性出错 #2502
Comments
很抱歉,没看懂你的意思,可以帮构建能直接运行重现问题的testcase么? |
JSONObject jsonObject = new JSONObject();
就是JSONObject 对象转字符串的时候,toString()和toJSONString() 的结果都是错误的, 是由于boolean类型的值转换的结果不对导致字符串的格式异常 |
我这里没有重现问题,你能帮调试下这个方法么?com.alibaba.fastjson2.JSONWriterUTF16#writeBool package com.alibaba.fastjson2;
class JSONWriterUTF16
public void writeBool(boolean value) {
int minCapacity = off + 5;
if (minCapacity >= this.chars.length) {
ensureCapacity(minCapacity);
}
char[] chars = this.chars;
int off = this.off;
if ((context.features & WriteBooleanAsNumber.mask) != 0) {
chars[off++] = value ? '1' : '0';
} else {
if (!value) {
chars[off++] = 'f';
}
UNSAFE.putLong(chars, ARRAY_CHAR_BASE_OFFSET + ((long) off << 1), value ? TRUE_64 : ALSE_64);
off += 4;
}
this.off = off;
}
} 看下chars,off这些变量发生啥变化了 |
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.50-SNAPSHOT/ |
最新版本的快照版本已经在多种aarch64架构的服务器上通过JDK8/11/17测试,包括:
|
问题描述
简要描述您碰到的问题。
碰到JSONObject转换json字符串时格式错误问题,刚开始运行正常,运行一段时间就会出错,出错后就会一直存在,重启服务后就有好了
服务器是华为云鲲鹏 kylinV10 aarch64 ,程序是部署在docker容器中,docker容器操作系统是centos8 aarch64,
环境信息
请填写以下信息:
重现步骤
如何操作可以重现该问题:
偶尔出现,一旦出现一直存在
SONObject licenseObj = null;
......
logger.info("loginValidateredirect==>licenseObj:{}", licenseObj);
logger.info("loginValidateredirect==>licenseObj.toString() = {}", licenseObj.toString());
logger.info("loginValidateredirect==>JSON.toJSONString(licenseObj) = {}", JSON.toJSONString(licenseObj));
期待的正确结果
对您期望发生的结果进行清晰简洁的描述。
相关日志输出
请复制并粘贴任何相关的日志输出。
附加信息
如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。
The text was updated successfully, but these errors were encountered: