简体   繁体   English

在Kotlin上,杰克逊ObjectMapper.readValue()导致java.lang.IllegalStateException:readValue(content,jacksonTypeRef <T> ())不能为null

[英]On Kotlin jackson ObjectMapper.readValue() causes java.lang.IllegalStateException: readValue(content, jacksonTypeRef<T>()) must not be null

On crashlytics I am getting an java.lang.IllegalStateException: readValue(content, jacksonTypeRef<T>()) must not be null exception on the 4th line. 在crashlytics上,我收到java.lang.IllegalStateException: readValue(content, jacksonTypeRef<T>()) must not be null在第四行java.lang.IllegalStateException: readValue(content, jacksonTypeRef<T>()) must not be null异常。 I couldn't reproduce it. 我无法复制它。 I think mapper.readValue(string) is returning null where is shouldn't. 我认为mapper.readValue(string)在不应该返回null的地方。 I handled the string being null case so other than string being null what could cause mapper.readValue(string) to return null so I end up with this exception and what is possible way to reproduce this error? 我处理了字符串为null的情况,所以除了string为null之外,这可能导致mapper.readValue(string)返回null,所以我最终mapper.readValue(string)此异常,并且有什么可能的方法来重现此错误?

var token: token? = null
    get() {
       val string = sharedPreferences.getString(TOKEN_KEY, null)
       field = if (string == null) null else mapper.readValue(string)
       return field     
    }
    set(value) {
        field = value
        val json = mapper.writeValueAsString(value)
        sharedPreferences.edit().putString(TOKEN_KEY, json).apply()
    }

事实证明sharedPreferences.getString(TOKEN_KEY, null)在这种情况下, sharedPreferences.getString(TOKEN_KEY, null)返回“ null”字符串,而mapper.readValue(string)返回null

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalStateException: TextView 不能为 null (Android/Kotlin) - java.lang.IllegalStateException: TextView must not be null (Android/Kotlin) Kotlin Android扩展:java.lang.IllegalStateException:视图不能为null - Kotlin Android Extensions : java.lang.IllegalStateException: view must not be null java.lang.IllegalStateException:[TextView]不能为null - java.lang.IllegalStateException: [TextView] must not be null java.lang.IllegalStateException:cardProductItem不能为null - java.lang.IllegalStateException: cardProductItem must not be null Kotlin-java.lang.IllegalStateException:ViewStub必须具有非null的ViewGroup viewParent - Kotlin - java.lang.IllegalStateException: ViewStub must have a non-null ViewGroup viewParent 引起:java.lang.IllegalStateException:TextView 不能为空 - Caused by: java.lang.IllegalStateException: TextView must not be null 将onCreateAnimation FATAL EXCEPTION重写为java.lang.IllegalStateException:不能为null - override onCreateAnimation FATAL EXCEPTION to java.lang.IllegalStateException : must not be null java.lang.IllegalStateException: recyclerview_latestmessage 不能是 null - java.lang.IllegalStateException: recyclerview_latestmessage must not be null 错误 java.lang.IllegalStateException:other 不能是 null - Error java.lang.IllegalStateException:other must not be null java.lang.IllegalStateException目标主机不能为null连接到数据库 - java.lang.IllegalStateException Target host must not be null connecting to database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM