Of a BUG Fastjson

fastjson version used in the project are: 1.1.41, sudden inexplicable abnormality after restarting the server line today, and again before this exception had not occurred, this anomaly like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
com.alibaba.fastjson.JSONException: write javaBean error
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:212) ~[fastjson-1.1.41.jar:na]
at Serializer_6.write1(Unknown Source) ~[na:na]
at Serializer_6.write(Unknown Source) ~[na:na]
at com.alibaba.fastjson.serializer.JSONSerializer.write(JSONSerializer.java:369) ~[fastjson-1.1.41.jar:na]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:418) ~[fastjson-1.1.41.jar:na]
at com.alibaba.fastjson.JSON.toJSONString(JSON.java:568) ~[fastjson-1.1.41.jar:na]
...
...
...
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
Caused by: java.lang.ClassCastException: com.google.common.collect.Lists$TransformingSequentialList cannot be cast to com.xxx.common.dto.pager.PagerData
at Serializer_9.write1(Unknown Source) ~[na:na]
at Serializer_9.write(Unknown Source) ~[na:na]
at com.alibaba.fastjson.serializer.ObjectFieldSerializer.writeValue(ObjectFieldSerializer.java:115) ~[fastjson-1.1.41.jar:na]
at com.alibaba.fastjson.serializer.ObjectFieldSerializer.writeProperty(ObjectFieldSerializer.java:68) ~[fastjson-1.1.41.jar:na]
at com.alibaba.fastjson.serializer.JavaBeanSerializer.write(JavaBeanSerializer.java:194) ~[fastjson-1.1.41.jar:na]
... 66 common frames omitted

Puzzling, because the object of my return is simply not com.xxx.common.dto.pager.PagerData the object information, why is there this error, it was very strange in the sequence of the time. People are very puzzled that this error occurred after restarting the server. After all lines have been in error, then the solution under so I tried two methods:

  1. Restart the server again
    to restart the server several times, the error remains, only a small adjustment code (fundamental and error issues irrelevant), but they reported this error to start the server, to kneel!
  2. Other libraries quickly found a temporary replacement json
    json framework after all, I was familiar with several of the lower so he can rush to use Gson (google produced json framework) temporarily replaces fastjson of json serialized output, problem solved! ! !

Then is the problem of finding embarked on the road, find fastjson the github site, issue the list after some searching to find issue and finally found a very similar problem I encountered:

  1. issue 60
  2. issue 107
    case and I are basically the same, but I fastjson version of the bug version also happens to fall on the interval they describe.
    fastjson developers wenshao reply 1.1.42 repair

I then hurried to the Maven repository view fastjson version, enlightened, a look version has evolved a lot, the latest version is already 1.2.7, 1.2.7 update code maven to rely on, and then test to publish online, multiple reboots determining that no longer appears mandatory class cast exception.

About the cause of the error cause, there is no depth to understand is what causes it, because this anomaly has some chance, verifiability relatively poor, online server is also the occasional appearance. Code is no clear submitted at the time of submission which fixes this bug, and so on back have time to look at this issue.

: Original large column  a BUG Fastjson of


Guess you like

Origin www.cnblogs.com/wangziqiang123/p/11618225.html