I have a RESTful API on Jersey 2.17 with Jackson on JDK8. It is JSON style API. This API accepts a Java object, it has this field:
我在Jersey 2.17上有一個RESTful API,Jackson在JDK8上。它是JSON樣式的API。此API接受Java對象,它具有以下字段:
@JsonProperty("processEndTime")
public Timestamp getRunDate() {
return runDate;
}
@JsonProperty("processEndTime")
public void setRunDate(Timestamp runDate) {
this.runDate = runDate;
}
Now when I submit a small number, it works perfectly like this:
現在,當我提交一個小數字時,它的工作原理如下:
"processEndTime" : 1434989360,
But it fails when the number is big one, like this:
但是當數字很大時它會失敗,如下所示:
"processEndTime" : 1434989360380,
The most weird thing is that I had a Jmeter test case, it sent the exact the same big number, it can pass without any issues. I can verify this number on the server side and confirmed it is correctly passed.
最奇怪的是我有一個Jmeter測試用例,它發送了完全相同的大數字,它可以毫無問題地通過。我可以在服務器端驗證此號碼並確認它已正確通過。
The full error message is:
完整的錯誤消息是:
Can not deserialize instance of java.sql.Timestamp out of VALUE_NUMBER_FLOAT token at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@23117fbd; line: 1, column: 562] (through reference chain: com.abc.api.dto.MyClassA["processEndTime"])
無法在[來源:org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@23117fbd;中刪除VALUE_NUMBER_FLOAT令牌中的java.sql.Timestamp實例。 line:1,column:562](通過參考鏈:com.abc.api.dto.MyClassA [“processEndTime”])
Any suggestions?
有什么建議么?
1 个解决方案
#1
0
I figure out the issue:
我弄清楚了這個問題:
I did some converting in the request data:
我在請求數據中做了一些轉換:
JSONObject analysis = new JSONObject(templateAnalysis3);
data = analysis.toString();
this toString function will convert long number to E format:
這個toString函數會將長數轉換為E格式:
1434989360380 -> 1.43498936038E12
This E format is not supported and caused this failure.
不支持此E格式並導致此失敗。
I fixed it by using templateAnalysis3 directly:
我直接使用templateAnalysis3修復了它:
data = templateAnalysis3;