]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8534 Handle null values consistently both from server to client and
authorArtur Signell <artur@vaadin.com>
Fri, 16 Mar 2012 11:32:41 +0000 (13:32 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 16 Mar 2012 11:32:41 +0000 (13:32 +0200)
from client to server

src/com/vaadin/terminal/gwt/server/JsonCodec.java

index 6a2a0750ad7d87f28a5be828540c678104364f2f..5d2e39f10f244ac3cb4f2c6b6597a995e906d928 100644 (file)
@@ -203,7 +203,7 @@ public class JsonCodec implements Serializable {
             Paintable paintable = (Paintable) value;
             return combineTypeAndValue(JsonEncoder.VTYPE_PAINTABLE,
                     idMapper.getPaintableId(paintable));
-        } else if (getTransportType(value) != JsonEncoder.VTYPE_NULL) {
+        } else if (getTransportType(value) != null) {
             return combineTypeAndValue(getTransportType(value),
                     String.valueOf(value));
         } else {
@@ -317,16 +317,20 @@ public class JsonCodec implements Serializable {
         return outerArray;
     }
 
+    /**
+     * Gets the transport type for the value. Returns null if no transport type
+     * can be found.
+     * 
+     * @param value
+     * @return
+     * @throws JSONException
+     */
     private static String getTransportType(Object value) throws JSONException {
         if (null == value) {
             return JsonEncoder.VTYPE_NULL;
         }
         String transportType = typeToTransportType.get(value.getClass());
-        if (null != transportType) {
-            return transportType;
-        }
-        throw new JSONException("Unknown object type "
-                + value.getClass().getName());
+        return transportType;
     }
 
 }