Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.1, 3.6.3, 6.0
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      Looks like CharsRef.subSequence() is currently broken

      It is implemented as:

        @Override
        public CharSequence subSequence(int start, int end) {
          // NOTE: must do a real check here to meet the specs of CharSequence
          if (start < 0 || end > length || start > end) {
            throw new IndexOutOfBoundsException();
          }
          return new CharsRef(chars, offset + start, offset + end);
        }
      

      Since CharsRef constructor is (char[] chars, int offset, int length),
      Should Be:

        @Override
        public CharSequence subSequence(int start, int end) {
          // NOTE: must do a real check here to meet the specs of CharSequence
          if (start < 0 || end > length || start > end) {
            throw new IndexOutOfBoundsException();
          }
          return new CharsRef(chars, offset + start, end - start);
        }
      

        Activity

        Hide
        Robert Muir added a comment -

        +1, this definitely looks wrong

        Show
        Robert Muir added a comment - +1, this definitely looks wrong
        Hide
        Robert Muir added a comment -

        patch

        Show
        Robert Muir added a comment - patch
        Hide
        Tim Smith added a comment -

        looks good

        Show
        Tim Smith added a comment - looks good
        Hide
        Robert Muir added a comment -

        I think the out of bounds is correct (should not use offset, only the length)

        Throws:
            IndexOutOfBoundsException - if start or end are negative, if end is greater than length(), or if start is greater than end
        
        Show
        Robert Muir added a comment - I think the out of bounds is correct (should not use offset, only the length) Throws: IndexOutOfBoundsException - if start or end are negative, if end is greater than length(), or if start is greater than end
        Hide
        Tim Smith added a comment -

        it is, that's why i deleted the comment, just looked wrong to me for a moment

        Show
        Tim Smith added a comment - it is, that's why i deleted the comment, just looked wrong to me for a moment
        Hide
        Robert Muir added a comment -

        Tim: ah sorry I see. was a race condition with jira

        Show
        Robert Muir added a comment - Tim: ah sorry I see. was a race condition with jira
        Hide
        Commit Tag Bot added a comment -

        [trunk commit] Robert Muir
        http://svn.apache.org/viewvc?view=revision&revision=1431019

        LUCENE-4671: Fix CharsRef.subSequence method

        Show
        Commit Tag Bot added a comment - [trunk commit] Robert Muir http://svn.apache.org/viewvc?view=revision&revision=1431019 LUCENE-4671 : Fix CharsRef.subSequence method
        Hide
        Commit Tag Bot added a comment -

        [branch_4x commit] Robert Muir
        http://svn.apache.org/viewvc?view=revision&revision=1431029

        LUCENE-4671: Fix CharsRef.subSequence method

        Show
        Commit Tag Bot added a comment - [branch_4x commit] Robert Muir http://svn.apache.org/viewvc?view=revision&revision=1431029 LUCENE-4671 : Fix CharsRef.subSequence method
        Hide
        Robert Muir added a comment -

        Thank you Tim!

        Show
        Robert Muir added a comment - Thank you Tim!

          People

          • Assignee:
            Robert Muir
            Reporter:
            Tim Smith
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development