[
http://jira.magnolia-cms.com/browse/MAGNOLIA-3712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Grégory Joseph updated MAGNOLIA-3712:
-------------------------------------
Patch included: [Yes]
Testcase included: (was: [Yes])
Component/s: admininterface
> Off by one problem in LogViewerPage end() method.
> -------------------------------------------------
>
> Key: MAGNOLIA-3712
> URL: http://jira.magnolia-cms.com/browse/MAGNOLIA-3712
> Project: Magnolia
> Issue Type: Bug
> Security Level: Public
> Components: admininterface
> Environment: I saw this problem in Magnolia 4.4
> Reporter: Lee Haslup
> Assignee: Philipp Bärfuss
>
> If you try to view the last page ( click ">>" ) in a logfile that is some
> exact multiple of the page size in lines (eg 100 lines, 150 lines, etc.) the
> log viewer will display "File is Empty " and suppress the page navigation
> information and controls.
> The problem is in the end() method which reads
> {noformat}
> public String end() {
> if (this.fileSizeInLines > this.maxNumLinesPerPage) {
> this.currentPosition = this.fileSizeInLines -
> (this.fileSizeInLines % this.maxNumLinesPerPage);
> } else {
> currentPosition = 0;
> }
> displayFileContent();
> return VIEW_SHOW;
> }
> {noformat}
> The problem is that if fileSizeInLines is an even multiple of
> maxNumLinesPerPage then the modulo function returns zero and currentPosition
> is set to fileSizeInLines which, since the line offset is zero-based is the
> first line *after* the end of the log file.
> The following implementation should correct this problem and is
> computationally simpler into the bargain.
> {noformat}
> public String end() {
> if (this.fileSizeInLines > this.maxNumLinesPerPage) {
> this.currentPosition = ((this.fileSizeInLines - 1L) /
> this.maxNumLinesPerPage) * this.maxNumLinesPerPage ;
> } else {
> currentPosition = 0;
> }
> displayFileContent();
> return VIEW_SHOW;
> }
> {noformat}
> Lee
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.magnolia-cms.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------