Last Comment Bug 716811 - Local DB calls getAsBoolean for IS_FOLDER, schema uses integers, ClassCastException results.
: Local DB calls getAsBoolean for IS_FOLDER, schema uses integers, ClassCastExc...
Product: Firefox for Android
Classification: Client Software
Component: General (show other bugs)
: unspecified
: ARM Android
-- normal (vote)
: Firefox 12
Assigned To: Richard Newman [:rnewman]
: Sebastian Kaspari (:sebastian)
Depends on:
Blocks: 709289
  Show dependency treegraph
Reported: 2012-01-09 23:13 PST by Richard Newman [:rnewman]
Modified: 2012-01-30 03:04 PST (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Proposed patch. v1 (1.40 KB, patch)
2012-01-09 23:41 PST, Richard Newman [:rnewman]
blassey.bugs: review+ feedback-
Details | Diff | Splinter Review

Description User image Richard Newman [:rnewman] 2012-01-09 23:13:08 PST
01-09 23:09:46.828 E/ContentValues(10750): Cannot cast value for folder to a Boolean: 0
01-09 23:09:46.828 E/ContentValues(10750): java.lang.ClassCastException: java.lang.Integer
01-09 23:09:46.828 E/ContentValues(10750): 	at android.content.ContentValues.getAsBoolean(
01-09 23:09:46.828 E/ContentValues(10750): 	at org.mozilla.fennec_rnewman.db.BrowserProvider.insertInTransaction(
01-09 23:09:46.828 E/ContentValues(10750): 	at org.mozilla.fennec_rnewman.db.BrowserProvider.insert(
Comment 1 User image Richard Newman [:rnewman] 2012-01-09 23:19:14 PST
Looks like this is actually a Fennec bug. Pretty high priority; this blocks further testing of bookmarks sync.

(Well, so does "turn on local DB support", but I'm working around that :D)

lucasr, this one for you?

        private void createMobileBookmarksFolder(SQLiteDatabase db) {
            ContentValues values = new ContentValues();
            values.put(Bookmarks.GUID, Bookmarks.MOBILE_FOLDER_GUID);
            values.put(Bookmarks.IS_FOLDER, 1);
            values.put(Bookmarks.POSITION, 0);


            db.execSQL("CREATE TABLE " + TABLE_BOOKMARKS + "(" +
                    Bookmarks._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +
                    Bookmarks.TITLE + " TEXT," +
                    Bookmarks.URL + " TEXT," +
                    Bookmarks.IS_FOLDER + " INTEGER NOT NULL DEFAULT 0," +

versus the line that fails:

                String url = values.getAsString(Bookmarks.URL);
                ContentValues imageValues = extractImageValues(values, url);
                Boolean isFolder = values.getAsBoolean(Bookmarks.IS_FOLDER);

This should probably be

                Boolean isFolder = values.getAsInteger(Bookmarks.IS_FOLDER) == 1;

I don't know if the getAsBoolean version works elsewhere, but apparently it doesn't on Android 2.3.4 on the Galaxy S2.
Comment 2 User image Richard Newman [:rnewman] 2012-01-09 23:41:05 PST
Created attachment 587252 [details] [diff] [review]
Proposed patch. v1

Haven't tested this yet (blocked on another bug, and it's getting late), but it looks right...!
Comment 3 User image Richard Newman [:rnewman] 2012-01-10 00:31:29 PST

Thanks for the quick turnaround, Brad.

Note to self: flag for Aurora approval when this lands.
Comment 4 User image Ed Morley [:emorley] 2012-01-10 11:48:30 PST
Comment 5 User image Lucas Rocha (:lucasr) 2012-01-11 11:39:05 PST
Comment on attachment 587252 [details] [diff] [review]
Proposed patch. v1

Review of attachment 587252 [details] [diff] [review]:

This patch causes a NullPointerException when adding bookmarks. I submitted a patch in bug 707150 to fix that (given that the patch is already in mozilla-central). I think we should skip this patch from aurora and a slightly different version of my patch in bug 707150 instead.
Comment 6 User image Richard Newman [:rnewman] 2012-01-11 11:51:06 PST
(In reply to Lucas Rocha (:lucasr) from comment #5)

> I think we should skip this patch from aurora and a
> slightly different version of my patch in bug 707150 instead.

Comment 7 User image Brad Lassey [:blassey] (use needinfo?) 2012-01-27 23:36:58 PST
If this isn't going to aurora, please mark the whiteboard not-fennec-11
Comment 8 User image Richard Newman [:rnewman] 2012-01-27 23:53:40 PST
Lucas, did your fix get to Aurora yet?
Comment 9 User image Lucas Rocha (:lucasr) 2012-01-30 03:04:37 PST
This has already been fixed in Aurora:

Note You need to log in before you can comment on or make changes to this bug.