aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/main/java/org/sonar
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-04-20 21:12:40 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-04-21 00:39:27 +0400
commitfdf6f4dcc2a4ee620dde9cdb5e2909ec4bd8c7f9 (patch)
tree66e60139be70a9d5903ae44b8806664e87769158 /sonar-ws-client/src/main/java/org/sonar
parent07b20316ee247a1694eb9191f985cb2de2d08b49 (diff)
downloadsonarqube-fdf6f4dcc2a4ee620dde9cdb5e2909ec4bd8c7f9.tar.gz
sonarqube-fdf6f4dcc2a4ee620dde9cdb5e2909ec4bd8c7f9.zip
SONAR-2379 Fix ClassCastException in DependencyUnmarshaller
GwtUtils.getString returns string representation of a numeric field, so this is a contract in WSUtils.getString and JdkUtils.getString must not cast Object to String.
Diffstat (limited to 'sonar-ws-client/src/main/java/org/sonar')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java3
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java4
2 files changed, 4 insertions, 3 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
index 05aba34a4d1..93c308ca700 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java
@@ -50,7 +50,8 @@ public abstract class WSUtils {
public abstract Object getField(Object json, String field);
/**
- * @return String value of specified field from specified JSON object,
+ * @return value of a string field from specified JSON object,
+ * or string representation of a numeric field,
* or <code>null</code> if field does not exist
*/
public abstract String getString(Object json, String field);
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 008eddc2539..7ada6ae781c 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
@@ -36,8 +36,8 @@ public final class JsonUtils {
public static String getString(Map obj, String field) {
Object value = obj.get(field);
- if (value != null) {
- return (String) value;
+ if (value instanceof String || value instanceof Number) {
+ return value.toString();
}
return null;
}