今天线上遇到一个问题,从hbase里读取出来的数据在转换json后输出时出现异常:

java.lang.ArrayIndexOutOfBoundsException: 160
at com.alibaba.fastjson.serializer.SerializeWriter.writeStringWithDoubleQuote(SerializeWriter.java:868)
at com.alibaba.fastjson.serializer.SerializeWriter.writeStringWithDoubleQuote(SerializeWriter.java:602)
at com.alibaba.fastjson.serializer.SerializeWriter.writeString(SerializeWriter.java:1411)
at com.alibaba.fastjson.serializer.StringCodec.write(StringCodec.java:49)
at com.alibaba.fastjson.serializer.StringCodec.write(StringCodec.java:34)
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:188)
at com.alibaba.fastjson.serializer.ListSerializer.write(ListSerializer.java:158)
at com.alibaba.fastjson.serializer.MapSerializer.write(MapSerializer.java:188)
at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:369)
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:596)
at com.alibaba.fastjson.JSON.toString(JSON.java:590)
at java.lang.String.valueOf(String.java:2854)
at java.io.PrintStream.println(PrintStream.java:821)

从异常信息中可以看出是在json toString的时候出现了错误,可能是引号或者其它不可见字符导致的,查看实际数据并没有出现单双引号,但是出现了\t\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0,\t是不应该出现问题的,那问题就只可能是\u00A0 导致的,查看UNICODE对照表,发现\u00A0确实是一个不可见字符

(unicode 对照表:https://unicode-table.com/en/#control-character):

\u00A0转ASCII,正好是160

问题变得简单了,可能是fastjson 对不可见字符的支持问题,于是换了个最新版试一下,果然一切正常,问题是解决了,但是得找到具体原因,看了看源代码,当前使用的这个

版本(1.1.39) 确实有部分特殊字符未做处理。

可参考官方修正提交:https://github.com/alibaba/fastjson/commit/cdf7cb253e961666e2b3c2bdd423abe73ba4324a#diff-0

解决:java.lang.ArrayIndexOutOfBoundsException: 160 at com.alibaba.fastjson.serializer.SerializeWriter.writeStringWithDoubleQuote(SerializeWriter.java:868)的更多相关文章

  1. java.lang.ArrayIndexOutOfBoundsException: 160

    项目突然出现这个问题java.lang.ArrayIndexOutOfBoundsException: 160,找了好大半天没有找出来哪里的问题,最后发现时fastjson.jar 版本太低了造成的, ...

  2. 解决kylin报错:java.lang.ArrayIndexOutOfBoundsException: -1

    报错信息: -- ::, INFO [pool--thread-] cli.DictionaryGeneratorCLI: : Building snapshot of ENERGON_DM.DM_D ...

  3. Tomcat 或JBOSS java.lang.ArrayIndexOutOfBoundsException: 8192原因及其解决方法

    2018-04-02 09:24:55 org.apache.catalina.connector.CoyoteAdapter service 严重: An exception or error oc ...

  4. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

    场景:eclipse中编写java中用到数组 问题: 程序不报错但是运行过程中 终止,显示字样 “ Exception in thread "main" java.lang.Arr ...

  5. Tomcat 或JBOSS java.lang.ArrayIndexOutOfBoundsException: 8192 解决方案【转】

    错误信息: 2017-1-17 10:09:39 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() ...

  6. 阿里巴巴 fastjson-1.2.12.jar json解析异常java.lang.ClassFormatError: Invalid method Code length 66865 in class file com/alibaba/fastjson/serializer/ASMSerializer_6_UserKdlb

    承接上篇:fastjson反序列化LocalDateTime失败的问题java.time.format.DateTimeParseException: Text '2019-05-24 13:52:1 ...

  7. 解决Redisson出现Failed to instantiate [org.redisson.api.RedissonClient]: Factory method 'create' threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0的问题

    一.背景 最近项目中使用了redisson的哨兵模式来作为redis操作的客户端,然后一个意外出现了,启动报:Failed to instantiate [org.redisson.api.Redis ...

  8. java.lang.ArrayIndexOutOfBoundsException异常分析及解决

    这是一个非常常见的异常,从名字上看是数组下标越界错误,解决方法就是查看为什么下标越界. 下面是一个错误示例: Exception in thread "main" java.lan ...

  9. java.lang.ArrayIndexOutOfBoundsException 异常分析及解决

    参考:http://blog.csdn.net/javaeeteacher/article/details/4485834 这是一个非常常见的异常,从名字上看是数组下标越界错误,解决方法就是查看为什么 ...

随机推荐

  1. Oozie wordcount实战

    一.定义 基本概念 Action: An execution/computation task (Map-Reduce job, Pig job, a shell command). It can a ...

  2. 1 web应用

    web应用 Web应用程序是一种可以通过Web访问的应用程序,程序的最大好处是用户很容易访问应用程序,用户只需要有浏览器即可,不需要再安装其他软件.应用程序有两种模式C/S.B/S.C/S是客户端/服 ...

  3. 01,jupyter环境安装

    jupyter notebook环境安装 一.什么是Jupyter Notebook? 1. 简介 Jupyter Notebook是基于网页的用于交互计算的应用程序.其可被应用于全过程计算:开发.文 ...

  4. BZOJ 2907: 拜访神犇

    设最优策略为第一步向左走 那么肯定是走到最左边最优 需要补一些步数 一种是最右边的连着选,多出一倍代价 一种是不连着选,多出两倍代价 #include<cstdio> #include&l ...

  5. HDU 4405 Aeroplane chess(期望dp)

    Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  6. 以+scheduledTimerWithTimeInterval...的方式触发的timer,在滑动页面上的列表时,timer会暂定回调,为什么?如何解决?

    这里强调一点:在主线程中以+scheduledTimerWithTimeInterval...的方式触发的timer默认是运行在NSDefaultRunLoopMode模式下的,当滑动页面上的列表时, ...

  7. 【Perceptron Learning Algorithm】林轩田机器学习基石

    直接跳过第一讲.从第二讲Perceptron开始,记录这一讲中几个印象深的点: 1. 之前自己的直觉一直对这种图理解的不好,老按照x.y去理解. a) 这种图的每个坐标代表的是features:fea ...

  8. UnitOfWork知多少 【转】

    原文链接:https://www.cnblogs.com/sheng-jie/p/7416302.html 1. 引言 Maintains a list of objects affected by ...

  9. Day4 自定义控件/ListView/RecyclerView

    创建自定义控件 引入布局 在新增的title.xml中创建一个自定义的标题栏: <LinearLayout xmlns:android="http://schemas.android. ...

  10. Spring AOP的一个简单实现

    针对学习笔记(六)中的购买以及退货代码,我们加入AOP框架,实现同样一个功能. 首先配置XML:service采用和之前一样的代码,只是没有通过实现接口来实现,而是直接一个实现类.transactio ...