Changeset 18615

Show
Ignore:
Timestamp:
03.03.2009 13:59:17 (11 years ago)
Author:
mdewsnip
Message:

Changed GS2LuceneQuery.java so it now catches exceptions thrown trying to write the query result cache file and warns about them, but doesn't bother with the full stack trace. It won't affect the functionality if we can't write some cache files, it will just affect the speed of subsequent requests. Example exceptions are "permission denied" errors, or "filename too long" errors (the filter string can get very long in some collections). By Michael Dewsnip at DL Consulting Ltd.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • indexers/trunk/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneQuery.java

    r18614 r18615  
    626626    // Cache this query result, if desired 
    627627    if (query_result_caching_enabled) { 
    628         FileWriter query_result_cache_file_writer = new FileWriter(query_result_cache_file); 
    629         query_result_cache_file_writer.write(query_results_xml.toString()); 
    630         query_result_cache_file_writer.close(); 
     628        // Catch any exceptions thrown trying to write the query result cache file and warn about them, but don't 
     629        //   bother with the full stack trace. It won't affect the functionality if we can't write some cache 
     630        //   files, it will just affect the speed of subsequent requests. 
     631        // Example exceptions are "permission denied" errors, or "filename too long" errors (the filter string 
     632        //   can get very long in some collections) 
     633        try 
     634        { 
     635        FileWriter query_result_cache_file_writer = new FileWriter(query_result_cache_file); 
     636        query_result_cache_file_writer.write(query_results_xml.toString()); 
     637        query_result_cache_file_writer.close(); 
     638        } 
     639        catch (Exception exception) 
     640        { 
     641        System.err.println("Warning: Exception occurred trying to write query result cache file (" + exception + ")"); 
     642        } 
    631643    } 
    632644    }