summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-08-16 09:47:14 +0300
committerLeif Åstrand <leif@vaadin.com>2012-08-20 08:53:45 +0300
commit44758a2791a568f97a11e7da918444e4fffec84e (patch)
tree228ec297fa2362e5346ea59fdb672fae492f2613 /server/src
parenta80335107906f1c41c1f42d2462dd838e8ea5b6c (diff)
downloadvaadin-framework-44758a2791a568f97a11e7da918444e4fffec84e.tar.gz
vaadin-framework-44758a2791a568f97a11e7da918444e4fffec84e.zip
Don't decode enum as an object (#9333)
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/terminal/gwt/server/JsonCodec.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java
index 60197b0b3a..94d860a200 100644
--- a/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java
+++ b/server/src/com/vaadin/terminal/gwt/server/JsonCodec.java
@@ -165,6 +165,10 @@ public class JsonCodec implements Serializable {
} else if (targetType == JSONObject.class
|| targetType == JSONArray.class) {
return value;
+ } else if (Enum.class.isAssignableFrom(getClassForType(targetType))) {
+ Class<?> classForType = getClassForType(targetType);
+ return decodeEnum(classForType.asSubclass(Enum.class),
+ (String) value);
} else {
return decodeObject(targetType, (JSONObject) value,
connectorTracker);
@@ -420,9 +424,8 @@ public class JsonCodec implements Serializable {
}
}
- private static Object decodeEnum(Class<? extends Enum> cls, JSONObject value) {
- String enumIdentifier = String.valueOf(value);
- return Enum.valueOf(cls, enumIdentifier);
+ private static Object decodeEnum(Class<? extends Enum> cls, String value) {
+ return Enum.valueOf(cls, value);
}
private static String[] decodeStringArray(JSONArray jsonArray)
@@ -491,10 +494,6 @@ public class JsonCodec implements Serializable {
throws JSONException {
Class<?> targetClass = getClassForType(targetType);
- if (Enum.class.isAssignableFrom(targetClass)) {
- return decodeEnum(targetClass.asSubclass(Enum.class),
- serializedObject);
- }
try {
Object decodedObject = targetClass.newInstance();