From a6cb91dc4933f6e16cb3bc9cda333e4ac2a529c3 Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 1 Apr 2013 10:48:28 -0700 Subject: [PATCH] Catch exceptions when deserializing content values --- .../andlib/utility/AndroidUtilities.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java index 94c2d727e..f6f335072 100644 --- a/api/src/com/todoroo/andlib/utility/AndroidUtilities.java +++ b/api/src/com/todoroo/andlib/utility/AndroidUtilities.java @@ -393,16 +393,21 @@ public class AndroidUtilities { public void put(T object, String key, char type, String value) throws NumberFormatException; } + @SuppressWarnings("nls") private static void fromSerialized(String string, T object, SerializedPut putter) { String[] pairs = string.split("\\" + SERIALIZATION_SEPARATOR); //$NON-NLS-1$ for(int i = 0; i < pairs.length; i += 2) { - String key = pairs[i].replaceAll(SEPARATOR_ESCAPE, SERIALIZATION_SEPARATOR); - String value = pairs[i+1].substring(1); try { - putter.put(object, key, pairs[i+1].charAt(0), value); - } catch (NumberFormatException e) { - // failed parse to number - putter.put(object, key, 's', value); + String key = pairs[i].replaceAll(SEPARATOR_ESCAPE, SERIALIZATION_SEPARATOR); + String value = pairs[i+1].substring(1); + try { + putter.put(object, key, pairs[i+1].charAt(0), value); + } catch (NumberFormatException e) { + // failed parse to number + putter.put(object, key, 's', value); + } + } catch (IndexOutOfBoundsException e) { + Log.e("deserialize", "Badly formed serialization: " + string, e); } } }