Closed Bug 1082551 Opened 6 years ago Closed 5 years ago

wrong call in log4moz.js ( "this._fos().XXX(...)" should be "this._fos.XXX(...)" )

Categories

(Thunderbird :: General, defect)

x86_64
Linux
defect
Not set

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 43.0

People

(Reporter: just, Assigned: aryx)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Firefox/24.0
Build ID: 20140927221706

Steps to reproduce:

tried to use FileAppender


Actual results:

Error writing file:
TypeError: this._fos is not a function


Expected results:

file should have opened...

see https://bugzilla.mozilla.org/show_bug.cgi?id=470208

this._fos().write(message, message.length);
should be
this._fos.write(message, message.length);
(In reply to rene from comment #0
> Actual results:
> Error writing file:
> TypeError: this._fos is not a function
>
> this._fos().write(message, message.length);
> should be
> this._fos.write(message, message.length);

Code is here.
> http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/log4moz.js#745

Property, function, is defined by;
> 713 FileAppender.prototype = {
> 714   __proto__: Appender.prototype,
> 715 
> 716   __fos: null,
> 717   get _fos() {
> 718     if (!this.__fos)
> 719       this.openStream();
> 720     return this.__fos;
> 721   },

I believe following(you suggested) will produce "this._fos is undefined".
   this._fos.write(message, message.length);

I think;
   this._fos().write(message, message.length);
should be
   this.__fos.write(message, message.length);
or
   this.get_fos().write(message, message.length);

I guess "__fos" like one(two "_") is for internal use at deeper level of an Object. "this.get_fos()" like one is better used by higher level of an Object.

FYI.
"._fos." (not ".__fos.") is seen in log4moz.js.
> http://mxr.mozilla.org/comm-central/source/mailnews/db/gloda/modules/log4moz.js#783
> 778   doAppend: function RFApp_doAppend(message) {
> 779     if (message === null || message.length <= 0)
> 780       return;
> 781     try {
> 782       this.rotateLogs();
> 783       this._fos.write(message, message.length);   <=  Should be "this.get_fos().write(...)" or "this.__fos.write(...)"
> 784     } catch(e) {
> 785       dump("Error writing file:\n" + e);
> 786     }
Summary: wrong call in log4moz.js → wrong call in log4moz.js ( "this._fos.XXX(...)" and "this._fos().XXX(...)" should be "this.get_fos().XXX(...)" or "this.__fos.XXX(...)" )
wada wrote:
>   this._fos().write(message, message.length);
>should be
>   this.__fos.write(message, message.length);
>or
>   this.get_fos().write(message, message.length);

no, this._fos (one _, without brackets) uses the getter and delivers this.__fos (two slashes) while ensuring that the stream is already open.

I'm currently using the suggested change https://www.absorb.it/virtual-id/browser/modules/vI_log.js#L292 and it works
Sorry, it was "get _fos()" which is getter, instead of "get_fos()"(no space). I missed a space.
Code in "doAppend: function FApp_doAppend" should be "this._fos.write", as written in "doAppend: function RFApp_doAppend".
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: wrong call in log4moz.js ( "this._fos.XXX(...)" and "this._fos().XXX(...)" should be "this.get_fos().XXX(...)" or "this.__fos.XXX(...)" ) → wrong call in log4moz.js ( "this._fos().XXX(...)" should be "this._fos.XXX(...)" )
Component: Untriaged → General
Attached patch patch, v1Splinter Review
Assignee: nobody → aryx.bugmail
Status: NEW → ASSIGNED
Attachment #8648487 - Flags: review?(mkmelin+mozilla)
Comment on attachment 8648487 [details] [diff] [review]
patch, v1

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

LGTM, r=mkmelin
Attachment #8648487 - Flags: review?(mkmelin+mozilla) → review+
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 43.0
You need to log in before you can comment on or make changes to this bug.