Closed Bug 1602326 Opened 4 years ago Closed 3 years ago

GetOfflineFileStream() can fail to return a stream even upon success.

Categories

(MailNews Core :: Backend, defect)

defect
Not set
normal

Tracking

(thunderbird_esr68 affected, thunderbird_esr78 wontfix)

RESOLVED FIXED
88 Branch
Tracking Status
thunderbird_esr68 --- affected
thunderbird_esr78 --- wontfix

People

(Reporter: benc, Assigned: benc)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

In particular, nsMsgDBFolder::GetOfflineFileStream.
Right at the top, there are some cases where a failure to access the database will result in a return code of NS_OK but the return value aFileStream being left untouched.

This seems unintuitive. If I called GetOfflineFileStream() and got NS_OK as the result code, then I'd expect to have a valid stream too.
Indeed, a lot of uses of GetOfflineFileStream() either check both the result code and the returned stream, or just ignore the code completely.

If NS_OK and no stream is indeed an acceptable return condition, then at least it should be documented as such in nsIMsgFolder.idl.

Blocks: 791893
See Also: → 1596036
Version: unspecified → Trunk

Just a note to myself from looking at Bug 1596036:
Seems pretty obvious to me that GetOfflineFileStream() should always return a non-null stream upon success (and failure should always return a fail code). The work is in making sure all the callers of GetOfflineFileStream() conform to that.

OK. Please don't forget the patch in attachment 9204913 [details] [diff] [review] of bug 1596036. There is some clean-up to do.

Assignee: nobody → benc
Status: NEW → ASSIGNED

So where to you intend to address comment #1 and comment #2?

Flags: needinfo?(benc)
Target Milestone: --- → 88 Branch

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/e40d2042c6b7
Make sure nsIMsgFolder.getOfflineFileStream() returns a stream or an error code. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED

Just going though the call sites of getOfflineFileStream() and giving them a freshen-up now it's return conditions have been straightened out.

Flags: needinfo?(benc)
Attachment #9208548 - Flags: review?(mkmelin+mozilla)

Doh, didn't realise I was using phab on this bug!

Nice, but you should reopen the bug.

Comment on attachment 9208548 [details] [diff] [review]
1602326-tidy-up-nsIMsgFolder-getOfflineFileStream-callers-1.patch

Review of attachment 9208548 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM, r=mkmelin
Attachment #9208548 - Flags: review?(mkmelin+mozilla) → review+
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/9d888b16cc38
Tidy up error handling for callers of nsIMsgFolder.getOfflineFileStream(). r=mkmelin
See Also: → 1709974
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: