Local DB calls getAsBoolean for IS_FOLDER, schema uses integers, ClassCastException results.

RESOLVED FIXED in Firefox 11

Status

()

Firefox for Android
General
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: rnewman, Assigned: rnewman)

Tracking

unspecified
Firefox 12
ARM
Android
Points:
---

Firefox Tracking Flags

(firefox11 fixed, firefox12 fixed, fennec11+)

Details

(Whiteboard: [inbound])

Attachments

(1 attachment)

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(ContentValues.java:413)
01-09 23:09:46.828 E/ContentValues(10750): 	at org.mozilla.fennec_rnewman.db.BrowserProvider.insertInTransaction(BrowserProvider.java:695)
01-09 23:09:46.828 E/ContentValues(10750): 	at org.mozilla.fennec_rnewman.db.BrowserProvider.insert(BrowserProvider.java:662)
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);

and

            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.
Assignee: rnewman → nobody
Status: ASSIGNED → NEW
Component: Android Sync → General
Product: Mozilla Services → Fennec Native
QA Contact: android-sync → general
Summary: Bookmarks repository layer uses integers rather than booleans → Local DB calls getAsBoolean for IS_FOLDER, schema uses integers, ClassCastException results.
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...!
Attachment #587252 - Flags: review?(blassey.bugs)
Attachment #587252 - Flags: feedback?(lucasr.at.mozilla)
Attachment #587252 - Flags: review?(blassey.bugs) → review+
Inbound:

https://hg.mozilla.org/integration/mozilla-inbound/rev/d33ae3516305

Thanks for the quick turnaround, Brad.

Note to self: flag for Aurora approval when this lands.
Assignee: nobody → rnewman
Status: NEW → ASSIGNED
Whiteboard: [inbound]

Comment 4

5 years ago
https://hg.mozilla.org/mozilla-central/rev/d33ae3516305
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 12
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.
Attachment #587252 - Flags: feedback?(lucasr.at.mozilla) → feedback-
(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.

Agreed!
If this isn't going to aurora, please mark the whiteboard not-fennec-11
tracking-fennec: --- → 11+
Lucas, did your fix get to Aurora yet?
This has already been fixed in Aurora:
https://hg.mozilla.org/releases/mozilla-aurora/rev/15bbd03602a4
status-firefox11: --- → fixed
status-firefox12: --- → fixed
You need to log in before you can comment on or make changes to this bug.