SourceForge.net Logo
Main Overview Wiki Issues Forum Build Fisheye
Issue Details (XML | Word | Printable)

Key: CMP-383
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Shay Banon
Reporter: Lukas Vlcek
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Compass

Incorrect calculation of page size in CompassSearchHelper

Created: 04/Apr/07 05:37 AM   Updated: 13/Mar/08 01:10 PM
Component/s: Compass::Core
Affects Version/s: 1.1 GA
Fix Version/s: 1.2 M1

File Attachments: 1. Text File CompassSearchHelper.patch (5 kB)



 Description  « Hide
The calculation of page size before detaching is invalid for the last page in the compassSearchHelper class. The issue is in performSearch(CompassSearchCommand searchCommand, CompassSession session) method where the last parameter of doProcessBeforeDetach() method is not correct in the following scenarios:

1) if (from > hits.getLength())
2) if ((from + iPageSize) > hitsLength)

hitsLength value should be replaced by (hitsLength-from)



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Lukas Vlcek added a comment - 04/Apr/07 05:38 AM
Here is the patch. Please review it.

Shay Banon added a comment - 04/Apr/07 03:00 PM
Applied the patch. Thanks!. Can you give the latest SNAPSHOT a go?

Lukas Vlcek added a comment - 16/Apr/07 03:37 PM
It works fine for me now.

— Minor note —
However, I have found one way how to get OutOfBoundaryException out of CompassSearchHelper today but I didn't have a chance to investigate it in detail yet. Imagine that there are 7 hits returned as a response to a given search term. Page size is set to 10. For the first page this works as expected (page contains just 7 hits). The problem is that there is nothing which prevents from asking for the next page (if the UI layer allows for this). In such case the OutOfBoundaryException is thrown because Compass tries to access array index at position [-3]. But in most cases CompassSearchHelper works fine if developer uses this object carefully - from the developer point of view there is a way how to prevent this situation.


Lukas Vlcek added a comment - 17/Apr/07 04:13 PM
I moved the issues into CMP-386 (http://jira.compassframework.org/browse/CMP-386).
In fact it was not OutOfBoundaryException but IllegalArgumentException.