Closed Bug 649024 Opened 14 years ago Closed 14 years ago

Make XPCOMUtils.defineLazyGetter retry if the function originally threw an exception

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: glandium, Unassigned)

Details

Attachments

(1 file)

Attached patch PatchSplinter Review
Currently, if the function defined as a lazy getter fails, the property ends up undefined. I think it would be better to make it retry (though I actually haven't checked if that leads to something unexpected in callers) I'm wondering if removing the "delete aObject[aName];" shouldn't be enough, but I'm not sure what kind of side effect that would have on garbage collection.
Attachment #525086 - Flags: review?(benjamin)
Removing the delete would have no effect on GC, but it would make the set not do anything, of course.
(In reply to comment #1) > Removing the delete would have no effect on GC, but it would make the set not > do anything, of course. Oh, so a property with a getter but no setter can't be overridden without being removed first. Kind of makes sense.
Attachment #525086 - Flags: review?(benjamin) → review?(sdwilsh)
Hmm, so the contact we've kinda had with this is that the callback would only ever be called once. What issue have you hit that makes you want this change?
See the startupInfo getter in https://addons.mozilla.org/en-US/firefox/files/browse/117663 and the saveData function in https://addons.mozilla.org/en-US/firefox/files/browse/117663 That's probably a very limited use-case, and I could do without modifying XPCOMUtils.defineLazyGetter, but I thought it could be useful.
(In reply to comment #4) > See the startupInfo getter in > https://addons.mozilla.org/en-US/firefox/files/browse/117663 and the saveData > function in https://addons.mozilla.org/en-US/firefox/files/browse/117663 > That's probably a very limited use-case, and I could do without modifying > XPCOMUtils.defineLazyGetter, but I thought it could be useful. I think it would be better if we didn't retry it. Do we at least do something useful and report an error by chance? (also, eww, _data does synchronous disk I/O)
(In reply to comment #5) > (In reply to comment #4) > > See the startupInfo getter in > > https://addons.mozilla.org/en-US/firefox/files/browse/117663 and the saveData > > function in https://addons.mozilla.org/en-US/firefox/files/browse/117663 > > That's probably a very limited use-case, and I could do without modifying > > XPCOMUtils.defineLazyGetter, but I thought it could be useful. > I think it would be better if we didn't retry it. Do we at least do something > useful and report an error by chance? In that case, the startup info may be incomplete if you get it too early, and we want to save all of it, so it's retried until it is complete, at which point it is cached. So in the more common case, it would be up to the caller to do error reporting if it wants to. > (also, eww, _data does synchronous disk I/O) it's only used when displaying the about:startup page, which needs these contents.
Are you OK with rolling your own cached getter since your use case is a bit special?
(In reply to comment #7) > Are you OK with rolling your own cached getter since your use case is a bit > special? I'm entirely ok with it. cf. comment 4. Feel free to WONTFIX.
That's what I'll do. Thanks for raising the issue though; happy to at least consider stuff like this :)
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
Attachment #525086 - Flags: review?(sdwilsh)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: