redis读取缓存数据时出现数值序列化异常
redis读取缓存数据时出现异常,异常信息如下:Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: WRONGTYPE Operation against a key holding the wrong kind of value,翻译出来的意思就是,redis命令执行异常:
redis读取缓存数据时出现异常,异常信息如下:Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: WRONGTYPE Operation against a key holding the wrong kind of value,翻译出来的意思就是,redis命令执行异常:错误的操作类型对应的key保存了错误的值类型,认真核对后发现是缓存中设置的为 string类型的value值,而在应用中则采用了list的方式进行数据的获取,造成操作类型和value 的类型不匹配的问题,后来就把redis中设置的value类型改成了list,然后再次操作出现新的异常,异常信息如下:
Could not read JSON: Invalid UTF-8 start byte 0x80
at [Source: (byte[])"“11.20.207.21”"; line: 1, column: 3]; nested exception is com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0x80
at [Source: (byte[])"“11.20.207.21”"; line: 1, column: 3]
其初是以为redisTemplate对值进行序列化的时候是按照json格式进行设置的,所以无法正常序列化字符串格式(PS:当时有点犯浑),然后将字符串改成了jsonObject格式"{"ip":"11.20.207.21"}",再次操作出现了新的异常,异常信息如下:
Could not read JSON: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object
at [Source: (byte[])"{"ip":"11.20.207.21"}"; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object
at [Source: (byte[])"{"ip":"11.20.207.21"}"; line: 1, column: 1]
然后没认真分析只看到 need JSON Array to contain贸然认为是是需要JSONArray的值类型,然后就把jsonObject类型改成了JSONArray格式{ "data": [ { "ip": "1.202.237.218" } ]}",再次操作仍出现异常,异常信息如下:
Could not read JSON: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Object
at [Source: (byte[])"{ "data": [ { "ip": "11.20.207.21"} ]}"; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Unexpected token (START_OBJECT), expected START_ARRAY: need JSON Array to contain As.WRAPPER_ARRAY type information for class java.lang.Objectat [Source: (byte[])"{ "data": [ {"ip": "11.20.207.21" } ]}"; line: 1, column: 1]
无奈只下只能把配置删除手动重新配置了一次,再次操作一切OK ^_^! 当是有点百撕不得其姐,今日复盘才发现问题根本原因:当时配置value时 值是从微信直接复制进来的,复制的时候可能复制了一个特殊字符进来,所以造成应用解析出现异常,其实异常提示已经很明确喽“[Source: (byte[])"“11.20.207.21”"; line: 1, column: 3]”,标红的地方就是特殊字条,只是肉眼看不到而已,再加上当时犯浑这么明显的提示都没分析出来*_*!,白白浪费大好时光啊。
特记录下来已飨回忆。
更多推荐
所有评论(0)