goller      2004/09/08 06:31:55

  Modified:    src/java/org/apache/lucene/queryParser QueryParser.jj
                        QueryParser.java
  Log:
  Fix ArrayIndexOutOfBoundsExceptions
  This patch is common to several patches
  for QueryParser see e.g. Bug 9110 and it cannot have any
  negative side effects.
  
  Revision  Changes    Path
  1.47      +2 -2      
jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj
  
  Index: QueryParser.jj
  ===================================================================
  RCS file: 
/home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- QueryParser.jj    7 Sep 2004 17:55:59 -0000       1.46
  +++ QueryParser.jj    8 Sep 2004 13:31:55 -0000       1.47
  @@ -200,13 +200,13 @@
   
       // If this term is introduced by AND, make the preceding term required,
       // unless it's already prohibited
  -    if (conj == CONJ_AND) {
  +    if (clauses.size() > 0 && conj == CONJ_AND) {
         BooleanClause c = (BooleanClause) clauses.elementAt(clauses.size()-1);
         if (!c.isProhibited())
           c.setOccur(BooleanClause.Occur.MUST);
       }
   
  -    if (operator == DEFAULT_OPERATOR_AND && conj == CONJ_OR) {
  +    if (clauses.size() > 0 && operator == DEFAULT_OPERATOR_AND && conj == CONJ_OR) {
         // If this term is introduced by OR, make the preceding term optional,
         // unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b)
         // notice if the input is a OR b, first term is parsed as required; without
  
  
  
  1.14      +2 -2      
jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.java
  
  Index: QueryParser.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- QueryParser.java  3 Sep 2004 21:12:22 -0000       1.13
  +++ QueryParser.java  8 Sep 2004 13:31:55 -0000       1.14
  @@ -177,13 +177,13 @@
   
       // If this term is introduced by AND, make the preceding term required,
       // unless it's already prohibited
  -    if (conj == CONJ_AND) {
  +    if (clauses.size() > 0 && conj == CONJ_AND) {
         BooleanClause c = (BooleanClause) clauses.elementAt(clauses.size()-1);
         if (!c.isProhibited())
           c.setOccur(BooleanClause.Occur.MUST);
       }
   
  -    if (operator == DEFAULT_OPERATOR_AND && conj == CONJ_OR) {
  +    if (clauses.size() > 0 && operator == DEFAULT_OPERATOR_AND && conj == CONJ_OR) {
         // If this term is introduced by OR, make the preceding term optional,
         // unless it's prohibited (that means we leave -a OR b but +a OR b-->a OR b)
         // notice if the input is a OR b, first term is parsed as required; without
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to