Closed Bug 757946 Opened 12 years ago Closed 12 years ago

nsConverterOutputStream logs "WARNING: Flush() lost data!" at close if underlying stream is already closed

Categories

(Core :: Internationalization, defect)

defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla15

People

(Reporter: Irving, Assigned: Irving)

Details

Attachments

(1 file)

The warning is frightening but harmless; the sequence of events that brought this on are:

JS code creates an nsISafeOutputStream to write safely to a file, then wraps that stream in a nsIConverterOutputStream

Once all the bytes are written through the converter, the JS code calls ConverterOutputStream.flush() and then SafeOutputStream.finish() to close and rename the underlying file to its final name. The JS code *cannot* just call ConverterOutputStream.close(), because calling close() on the SafeOutputStream aborts the file save operation; the temporary is only moved into its final position if finish() is called.

So, the underlying OutputStream is closed but the ConverterOutputStream is not. Then, when JS GC destroys the ConverterOutputStream, the destructor calls close(), which calls flush(), which always tries to write() to the underlying OutputStream even if it doesn't have anything to write.

I'll attach a patch for that issue, but it would also be worth making nsIConverterOutputStream implement the nsISafeOutputStream API so that calling code could just finish() the ConverterOutputStream and have the right things happen all the way down.
Attachment #626541 - Flags: review?(smontagu) → review+
https://hg.mozilla.org/mozilla-central/rev/ea68a0638211
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: