facebook/facebook-android-sdk — pull request #246 by plowman (2011-10-27 21:16:08+00:00)
Title: Fix for Issue #160: ClassCastExceptions filling up the logs.

This is a simple fix that takes care of annoying log spam. Would love it if a Facebook engineer could pull this. :-)

For each request made to facebook using this library, 5-10 instances of the following message is logged:
```10-27 13:28:04.342: WARN/Bundle(3671): Key format expected byte[] but value was a java.lang.String. The default value was returned.
10-27 13:28:04.346: WARN/Bundle(3671): Attempt to cast generated internal exception:
java.lang.ClassCastException: java.lang.String
at android.os.Bundle.getByteArray(Bundle.java:1305)
at com.facebook.android.Util.encodePostBody(Util.java:52)
at com.facebook.android.Util.openUrl(Util.java:173)
at com.facebook.android.Facebook.request(Facebook.java:544)
at com.facebook.android.AsyncFacebookRunner$2.run(AsyncFacebookRunner.java:239)
```

This is caused by calling Bundle.getByteArray() on a key that maps to a value which cannot be cast to a byte array, for example a String. For example, this code would cause the above log message:

```
Bundle bundle = new Bundle();
bundle.putString("format", "json");
bundle.getByteArray("format");
```

Since we never need to call setByteArray() on this Bundle, and since all of our parameters are just plain Strings, I have changed a few lines to use Bundle.getString() and Bundle.setString() exclusively, and then check that Bundle.get() returns a String where we expect one.

I have tested this against all the API requests my client uses. The API requests continue to work and the log message no longer appears.