Skip to content
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] android kotlin反序列化出现ArrayIndexOutOfBoundsException #370

Closed
Alexxiaopang opened this issue May 28, 2022 · 3 comments
Closed
Assignees
Labels
bug Something isn't working kotlin
Milestone

Comments

@Alexxiaopang
Copy link

问题描述

Android Kotlin 反序列化时出现
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.alibaba.fastjson2.reader.ObjectReaderCreator.createObjectReaderWithCreator(ObjectReaderCreator.java:314)
at com.alibaba.fastjson2.reader.ObjectReaderCreator.createObjectReader(ObjectReaderCreator.java:570)
at com.alibaba.fastjson2.reader.ObjectReaderProvider.getObjectReader(ObjectReaderProvider.java:693)

环境信息

  • OS信息: 红米K40 Miui13.0.5,小米10s Miui13.0.3
  • JDK信息: Openjdk 1.8
  • 版本信息:Fastjson2 2.0.4 , kotlin版本 :1.6.0

重现步骤

1.只要调用to或者parseObject方法反序列化就会出现,

    
   data class TestBean(var test: String =“111”, val test2: String=“2222”)
   val data="{\"test\":\"111\"}".to<TestBean>()//这里就会报错
 
 
 //或者 

    data class TestBean(var test: String =“111”, val test2: String=“2222”)

    val dateStr=data.toJSONString()

   val data=dataStr.to<TestBean>()//这里就会报错
 
@Alexxiaopang Alexxiaopang added the bug Something isn't working label May 28, 2022
@wenshao wenshao added this to the 2.0.6 milestone May 28, 2022
wenshao added a commit that referenced this issue May 28, 2022
kotlin constructor parameter supports default value #370
@wenshao wenshao added the kotlin label May 29, 2022
@kraity
Copy link
Collaborator

kraity commented May 29, 2022

你好, kotlin构造参数已支持默认值了,可使用2.0.6-SNAPSHOT快照
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2-kotlin/2.0.6-SNAPSHOT/

@wenshao
Copy link
Member

wenshao commented Jun 4, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.6
问题已经修复,请用新版本

@wenshao wenshao closed this as completed Jun 4, 2022
@mixiaobu
Copy link

D/NET_LOG: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
您好,最新版2.0.19又出现差不多的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kotlin
Projects
None yet
Development

No branches or pull requests

4 participants