From 44758a2791a568f97a11e7da918444e4fffec84e Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 16 Aug 2012 09:47:14 +0300 Subject: Don't decode enum as an object (#9333) --- server/src/com/vaadin/terminal/gwt/server/JsonCodec.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'server') 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 cls, JSONObject value) { - String enumIdentifier = String.valueOf(value); - return Enum.valueOf(cls, enumIdentifier); + private static Object decodeEnum(Class 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(); -- cgit v1.2.3