From 7727f8c087ddfd4675d1b943e35f44122eddb275 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 27 Jun 2013 16:33:37 +0200 Subject: SONAR-4381 ClassCastException when unmarshalling response from manual measure WS --- .../src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java | 3 +++ .../src/test/resources/manual_measures/all_measures.json | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'sonar-ws-client') diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java index 0f9381fffac..c767b5602f4 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java @@ -69,6 +69,9 @@ public final class JsonUtils { public static Double getDouble(Map obj, String field) { Object value = obj.get(field); if (value != null) { + if (value instanceof Long) { + return ((Long) value).doubleValue(); + } return (Double) value; } return null; diff --git a/sonar-ws-client/src/test/resources/manual_measures/all_measures.json b/sonar-ws-client/src/test/resources/manual_measures/all_measures.json index 05bce196c2d..2adfa725223 100644 --- a/sonar-ws-client/src/test/resources/manual_measures/all_measures.json +++ b/sonar-ws-client/src/test/resources/manual_measures/all_measures.json @@ -3,7 +3,7 @@ "id":1, "metric":"burned_budget", "resource":"org.apache.struts:struts-parent", - "val":302.0, + "val":302.1, "created_at":"2011-07-27T10:22:34+0200", "updated_at":"2011-07-27T10:22:34+0200", "login":"admin", @@ -13,10 +13,10 @@ "id":2, "metric":"team_size", "resource":"org.apache.struts:struts-parent", - "val":555.0, + "val":555, "created_at":"2011-07-27T10:53:33+0200", "updated_at":"2011-07-27T10:53:33+0200", "login":"admin", "username":"Administrator" } -] \ No newline at end of file +] -- cgit v1.2.3