Bug 1321568 - Handle null and CharSequence prompt values; r=me
authorJim Chen <nchen@mozilla.com>
Thu, 08 Dec 2016 14:46:08 -0500
changeset 370404 c6face1d7183eea175fd7b00e576d3312f3fd14c
parent 370403 b3b5af78a162b11a9a838087c0f6ad3567eeb55e
child 370405 2be3e937ecd92ed4cd0404cfaa71fa451805e8fd
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1321568
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1321568 - Handle null and CharSequence prompt values; r=me Correctly handle null values and CharSequence values (that are not Strings) returned by prompt inputs. r=me for trivial patch.
mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
--- a/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
+++ b/mobile/android/base/java/org/mozilla/gecko/prompts/Prompt.java
@@ -252,28 +252,30 @@ public class Prompt implements OnClickLi
         for (final PromptInput input : mInputs) {
             if (input == null) {
                 continue;
             }
 
             final String id = input.getId();
             final Object value = input.getValue();
 
-            if (value instanceof Boolean) {
+            if (value == null) {
+                result.putBundle(id, null);
+            } else if (value instanceof Boolean) {
                 result.putBoolean(id, (Boolean) value);
             } else if (value instanceof Double) {
                 result.putDouble(id, (Double) value);
             } else if (value instanceof Integer) {
                 result.putInt(id, (Integer) value);
-            } else if (value instanceof String) {
-                result.putString(id, (String) value);
+            } else if (value instanceof CharSequence) {
+                result.putString(id, value.toString());
             } else if (value instanceof GeckoBundle) {
                 result.putBundle(id, (GeckoBundle) value);
             } else {
-                throw new UnsupportedOperationException();
+                throw new UnsupportedOperationException(value.getClass().toString());
             }
         }
     }
 
     /* Adds the selected button to a result. This should only be called if there
      * are no lists shown on the dialog, since they also write their results to the button
      * attribute.
      */