Ignore:
Timestamp:
2018-11-16T17:19:53+13:00 (5 years ago)
Author:
ak19
Message:

Preliminary stage before tackling a different bug. This commit is a bugfix to the index folder file locking problem that occurs on Windows when coll deactivate doesn't close all file handles to the coll index folder after doing some lucene searches. Inspecting the code revealed the possibility of another different bug, for which Kathy devised a test to confirm its existence. After testing, found the bug is real: multiple queries configure the same query object (and its internal reader object) but the last configuration is always used to run a search. For example, one user wants to search a lucene collection at doc level and a second user wants to search the same collection at section level. The 2nd user's configuration wins if they configure between the first person's query object being configured and its query being run. So the first person now ends up seeing search results that are at section level.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/lucene-gs/src/org/greenstone/LuceneWrapper4/GS2LuceneQuery.java

    r32509 r32609  
    105105        }
    106106
    107         try {
     107        try {   
     108       
     109            if(reader != null) {
     110                    reader.close();
     111                    searcher = null;
     112            }   
     113           
    108114        Directory full_indexdir_dir = FSDirectory.open(new File(full_indexdir));
    109115
    110116        reader = DirectoryReader.open(full_indexdir_dir); // Returns a IndexReader reading the index in the given Directory. now readOnly=true by default, and therefore also for searcher
    111117        searcher = new IndexSearcher(reader); // during searcher.search() will get it to compute ranks when sorting by fields
    112        
     118       
    113119        this.sorter = new Sort(new SortField(this.sort_field, this.sort_type, this.reverse_sort));
    114120    }
     
    351357        // No other methods should be called after this has been called.
    352358        }
     359       
    353360    } catch (IOException exception) {
    354361        exception.printStackTrace();
     
    661668       
    662669        if (!queryer.initialise()) {
     670            queryer.cleanUp(); // will close reader object IF reader was instantiated
    663671        return;
    664672        }
     
    683691        }
    684692        }
    685         queryer.cleanUp();
     693        queryer.cleanUp();
    686694    }
    687695    catch (IOException exception) {
Note: See TracChangeset for help on using the changeset viewer.