Details
-
Bug
-
Resolution: Outdated
-
Neutral
-
None
-
None
-
None
-
I saw this problem in Magnolia 4.4
Description
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
public String end() {
if (this.fileSizeInLines > this.maxNumLinesPerPage) {
this.currentPosition = this.fileSizeInLines - (this.fileSizeInLines % this.maxNumLinesPerPage);
} else {
currentPosition = 0;
}
displayFileContent();
return VIEW_SHOW;
}
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.
public String end() {
if (this.fileSizeInLines > this.maxNumLinesPerPage) {
this.currentPosition = ((this.fileSizeInLines - 1L) / this.maxNumLinesPerPage) * this.maxNumLinesPerPage ;
} else {
currentPosition = 0;
}
displayFileContent();
return VIEW_SHOW;
}
Lee
Checklists
Acceptance criteria